-
-
Save MadFaill/9c048410f1cdc2b176931bc82416dff2 to your computer and use it in GitHub Desktop.
strange nginx behaviour with error_page + proxy_pass
This file contains 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
I expected the first configuration below, simple.conf, to work just fine. | |
But it doesn't. My app server receives the second hit with the same URI as the first hit. | |
On the second config, wtf.conf, I keep the original URL on a variable to use in the error redirect. | |
My question is this: why doesn't the first simple.conf configuration works? |
This file contains 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
server { | |
server_name my.site; | |
listen 80; | |
location / { | |
proxy_pass http://127.0.0.1:5000; | |
proxy_intercept_errors on; | |
} | |
error_page 404 /errors/404; | |
location /errors/ { | |
proxy_pass http://127.0.0.1:5000; | |
internal; | |
} | |
} |
This file contains 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
server { | |
server_name my.site; | |
listen 80; | |
location / { | |
## Keep copy of original URL | |
set $orig_uri $uri$is_args$args; | |
proxy_pass http://127.0.0.1:5000; | |
proxy_intercept_errors on; | |
} | |
error_page 404 /errors/404; | |
location /errors/ { | |
rewrite . /errors/404$orig_uri break; | |
proxy_pass http://127.0.0.1:5000; | |
internal; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment