I am trying to pass off all calls to /api to my webservice but I keep getting 404s with the following config. Calls to / return index.html as expected. Does anyone know why?
Just want to remind others that the slash(backend*/*) after your proxy_pass url is very important!
if the config is
location /api/ {
proxy_pass http://backend;
}
and you visit http://abc.xyz/api/endpoint
, you would be direct to http://backend/api/endpoint
;
if the config is
location /api/ {
proxy_pass http://backend/;
}
and you visit http://abc.xyz/api/endpoint
, you would be directed to
http://backend/endpoint
.
That's the difference.
For more, refer to: Nginx reverse proxy return 404