Last active
October 2, 2020 15:01
-
-
Save kalsan/a61b4b09167cc4cfaa75326bae2b48cc to your computer and use it in GitHub Desktop.
Examples demonstrating how Nginx treats slashes in `location` and `proxy_pass` statements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| How Nginx treats slashes in `location` and `proxy_pass` statements: | |
| Base URL: https://www.my.web.site/pre/fix/page.html | |
| Our decuced rules, apply for each block A-C: | |
| 1: Location is passed on without change | |
| 2: Location is removed, '/' is added | |
| 3: Location is removed, 'pre/fix' is added | |
| 4: Location is removed, 'pre/fix/' is added | |
| Explanation of the following table: | |
| `location` stmt `proxy_pass` statement HTTP request that the backend 12.34.56.778 is seeing | |
| A: | |
| location / http://12.34.56.78 GET /pre/fix/page.html HTTP/1.0 | |
| location / http://12.34.56.78/ GET /pre/fix/page.html HTTP/1.0 | |
| location / http://12.34.56.78/pre/fix GET /pre/fixpre/fix/page.html HTTP/1.0 | |
| location / http://12.34.56.78/pre/fix/ GET /pre/fix/pre/fix/page.html HTTP/1.0 | |
| B: | |
| location /pre/fix http://12.34.56.78 GET /pre/fix/page.html HTTP/1.0 | |
| location /pre/fix http://12.34.56.78/ GET //page.html HTTP/1.0 | |
| location /pre/fix http://12.34.56.78/pre/fix GET /pre/fix/page.html HTTP/1.0 | |
| location /pre/fix http://12.34.56.78/pre/fix/ GET /pre/fix//page.html HTTP/1.0 | |
| C: | |
| location /pre/fix/ http://12.34.56.78 GET /pre/fix/page.html HTTP/1.0 | |
| location /pre/fix/ http://12.34.56.78/ GET /page.html HTTP/1.0 | |
| location /pre/fix/ http://12.34.56.78/pre/fix GET /pre/fixpage.html HTTP/1.0 | |
| location /pre/fix/ http://12.34.56.78/pre/fix/ GET /pre/fix/page.html HTTP/1.0 | |
| D: | |
| location pre/fix http://12.34.56.78 404 (this is the reply to the client, nginx does not contact backend) | |
| location pre/fix http://12.34.56.78/ 404 | |
| location pre/fix http://12.34.56.78/pre/fix 404 | |
| location pre/fix http://12.34.56.78/pre/fix/ 404 | |
| E: | |
| location pre/fix/ http://12.34.56.78 404 | |
| location pre/fix/ http://12.34.56.78/ 404 | |
| location pre/fix/ http://12.34.56.78/pre/fix 404 | |
| location pre/fix/ http://12.34.56.78/pre/fix/ 404 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment