nginx
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| nginx [2026/01/07 00:02] – [Reference Notes] lex | nginx [2026/01/08 00:39] (current) – lex | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| ===== Reference Notes ===== | ===== Reference Notes ===== | ||
| Actually pretty decent reference [[https:// | Actually pretty decent reference [[https:// | ||
| - | === location === | + | ==== location |
| - | '' | + | Nginx reference, [[https:// |
| - | / refers to the URI, so in this case the root URI | + | < |
| + | location [ = | ~ | ~* | ^~ ] uri { ... } | ||
| + | location @name { ... } | ||
| + | </code> | ||
| + | '' | ||
| + | Without any of them, nginx will match request as prefix url, so it can be longer.\\ | ||
| + | '' | ||
| + | '' | ||
| + | '' | ||
| + | '' | ||
| + | === 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 '' | ||
| + | |||
| + | === Examples === | ||
| + | |||
| + | < | ||
| + | location / { | ||
| + | } | ||
| + | </ | ||
| + | Matches with '' | ||
| + | |||
| + | < | ||
| + | location /images/ { | ||
| + | } | ||
| + | </ | ||
| + | Matches with '' | ||
| + | |||
| + | < | ||
| + | location ~ \.(gif|jpg|png)$ { | ||
| + | root / | ||
| + | } | ||
| + | </ | ||
| + | ~ means the following is a regex. In this case, every address ending on gif, jpg, or png will return a file from / | ||
| ===== Examples ===== | ===== Examples ===== | ||
| ==== Basic Proxy Pass ==== | ==== Basic Proxy Pass ==== | ||
nginx.1767744144.txt.gz · Last modified: by lex
