User Tools

Site Tools


nginx

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
nginx [2026/01/07 00:17] – [Reference Notes] lexnginx [2026/01/08 00:39] (current) lex
Line 2: Line 2:
 ===== Reference Notes ===== ===== Reference Notes =====
 Actually pretty decent reference [[https://nginx.org/en/docs/beginners_guide.html|Nginx Beginners Guide]] Actually pretty decent reference [[https://nginx.org/en/docs/beginners_guide.html|Nginx Beginners Guide]]
-=== location ===+==== location ===
 +Nginx reference, [[https://nginx.org/en/docs/http/ngx_http_core_module.html#location]] 
 +<code> 
 +location [ = | ~ | ~* | ^~ ] uri { ... } 
 +location @name { ... } 
 +</code> 
 +''='', ''~'', ''~*'', ''^~'' are all optional parameters 
 + 
 +Without any of them, nginx will match request as prefix url, so it can be longer.\\ 
 +''='' Exact match, stops further searching\\ 
 +''~'' Regex, case sensitive\\ 
 +''~*'' Regex, case insensitive\\ 
 +''^~'' Prefix match without following regex\\ 
 +=== Logic === 
 +Nginx divides it into prefix locations and regex locations. It starts going through prefix locations, selecting the longest that matches. With that selection, nginx runs through the regex matches. If ''='' or ''^~'' is used, regex matching won't be done. 
 + 
 +=== Examples === 
 <code> <code>
     location / {     location / {
-        root /data/www; 
     }     }
 </code> </code>
-refers to the URI, so in this case the root URI\\ +Matches with ''http://someweb.site/'' and any address proceeding the ''/'', so it also matches ''http://someweb.site/cool/resource''.
-So the above returns files in ''/data/www''+
  
 <code> <code>
     location /images/ {     location /images/ {
-        root /data; 
     }     }
 </code> </code>
-Returns files in /data/images/+Matches with ''http://someweb.site/images'' and any address proceeding the ''/images'', so it also matches ''http://someweb.site/cool/resource''.
  
 <code> <code>
nginx.1767745078.txt.gz · Last modified: by lex

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki