Nginx webserver configuration

From WickyWiki
Revision as of 15:05, 21 September 2023 by Wilbert (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Some notes on Nginx webserver configuration.

Note:

  • Ultimately one location -context is selected to proces the request
  • Usually a request uri matches multiple location contexts, the selected context is based on a number of conditions. This depends on the option, length of the match, and order of appearance.
  • Location allows for a prefix $uri -match by default. Other possibilities are an exact match (option "=") or a regular expression (option "~")

Understanding this, you may also understand that adding a new location can cause requests to be captured that were previously handled by other locations, breaking your setup.

# 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;
}