Answer the question
In order to leave comments, you need to log in
How to set up a proxy without a 301 redirect?
upstream starter_api {
server 127.0.0.1:7777;
}
location /api/ {
proxy_pass http://starter_api/;
}
location /api/
, a request for to http://example.com/api
is redirected to http://example.com/api/
. The difference is one lousy slash. location /api
, then deeper urls stop working, for example http://example.com/api/articles
. Answer the question
In order to leave comments, you need to log in
location /api/ {
proxy_pass http://starter_api/;
}
location = /api {
proxy_pass http://starter_api/;
}
location /api {
rewrite ^/api(.*)$ /$1 last;
proxy_pass http://starter_api/;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question