Nginx proxy_pass caveat
protip: location /foo/ {proxy_pass domain:port/} the / at the end of the domain:port will avoid nginx to send the path /foo/ to the request
— Jhimy F. Villar (@stjhimy) March 16, 2015
Explaining this tweet:
Let’s say you have /foo proxying to 127.0.0.1:3000
location /foo/ {
proxy_pass http://127.0.0.1:3000/;
}
when you hit /foo it proxy to 127.0.0.1:3000/
location /foo/ {
proxy_pass http://127.0.0.1:3000;
}
when you hit /foo it proxy to 127.0.0.1:3000/foo
The only difference is the “/” at the end of “127.0.1:3000/”