Reputation: 95
I have a domain binging a IP:
a.a.com -> 1.1.1.1
In 1.1.1.1
has a nginx , for access a.a.com/bbb/
to 2.2.2.2
's django service.
`
#1.1.1.1
server {
listen 8090;
server_name localhost;
location /bbb/ {
proxy_pass 2.2.2.2:8000;
}
}
`
when I input a.a.com/bbb/
, I can access, it's ok.
But when Django login's session timeout , It automatic redirect a.a.com:8090/bbb/
.
I want to ask how to automatic redirect a.a.com/bbb/
.
ps. the 8090 port cant access
Sorry my poor English , Thanks.
Upvotes: 0
Views: 747
Reputation: 6939
Use proxy_redirect off
:
location /bbb/ {
proxy_pass 2.2.2.2:8000;
proxy_redirect off;
}
proxy_redirect off
tells nginx that, if the backend returns an HTTP redirect, it should leave it as is. (By default, nginx assumes the backend is stupid and tries to be smart; if the backend returns an HTTP redirect that says "redirect to http://localhost:8000/somewhere", nginx replaces it with something similar to "http://yourowndomain.com/somewhere", or, in your case, "http://yourowndomain.com:8090/somewhere". Django is smart enough so there is no need for nginx to do such things.)
Upvotes: 1