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:02] – [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 ==== 
-''location / {''\\ +Nginx reference, [[https://nginx.org/en/docs/http/ngx_http_core_module.html#location]] 
-refers to the URIso in this case the root URI+<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>
 +    location / {
 +    }
 +</code>
 +Matches with ''http://someweb.site/'' and any address proceeding the ''/'', so it also matches ''http://someweb.site/cool/resource''.
 +
 +<code>
 +    location /images/ {
 +    }
 +</code>
 +Matches with ''http://someweb.site/images'' and any address proceeding the ''/images'', so it also matches ''http://someweb.site/cool/resource''.
 +
 +<code>
 +    location ~ \.(gif|jpg|png)$ {
 +        root /data/images;
 +    }
 +</code>
 +~ means the following is a regex. In this case, every address ending on gif, jpg, or png will return a file from /data/images
 ===== Examples ===== ===== Examples =====
 ==== Basic Proxy Pass ==== ==== Basic Proxy Pass ====
nginx.1767744144.txt.gz · Last modified: by lex

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki