Nginx webserver configuration: Difference between revisions

From WickyWiki
Created page with "Category:Raspberry Pi Category:Linux Category:202309 Some notes on Nginx webserver configuration. * https://www.digitalocean.com/community/tutorials/understanding-the-nginx-configuration-file-structure-and-configuration-contexts * http://nginx.org/en/docs/beginners_guide.html Note: * Ultimately there is one location context selected to proces a request * It is possible that a request $uri matches multiple location contexts, in that case a context is selecte..."
 
mNo edit summary
Line 8: Line 8:


Note:
Note:
* Ultimately there is one location context selected to proces a request
* Ultimately 1 [http://nginx.org/en/docs/http/ngx_http_core_module.html#location location] contexts selected to proces a request
* It is possible that a request $uri matches multiple location contexts, in that case a context is selected, based on a number of conditions: options, length of the match, order of appearance
* It is possible that a request $uri matches multiple location contexts, in that case a context is selected, based on a number of conditions, like: options, length of the match, order of appearance
* location allows for a prefix $uri match by default. Other possibilities are an exact match (option "=") or a regular expression (option "~")


<source lang=bash>
<source lang=bash>

Revision as of 14:49, 21 September 2023


Some notes on Nginx webserver configuration.

Note:

  • Ultimately 1 location contexts selected to proces a request
  • It is possible that a request $uri matches multiple location contexts, in that case a context is selected, based on a number of conditions, like: options, length of the match, order of appearance
  • location allows for a prefix $uri match by default. Other possibilities are an exact match (option "=") or a regular expression (option "~")
# http context
server {
  #server 1 context
  listen 8080;
  server_name wjv.duckdns.org;

  location /urimatch1 {
    #virtual folder 1 context
    root /var/www/html;
  }

  location <option> /urimatch2 {
    #virtual folder 2 context
    return 200 'document_root=$document_root<br/> request_filename=$request_filename<br/> uri=$uri<br/';
    add_header Content-Type text/html;
  }
}

server {
  # server 2 context
  listen 8081;
}