我有一个绑定了IP的域名:
a.a.com -> 1.1.1.1
在1.1.1.1中有一个nginx,用于访问2.2.2.2的django服务的a.a.com/bbb/。
`
#1.1.1.1
server {
listen 8090;
server_name localhost;
location /bbb/ {
proxy_pass 2.2.2.2:8000;
}
}`
当我输入a.a.com/bbb/时,我可以访问,它是好的。
但是当Django登录的会话超时时,它会自动重定向a.a.com:8090/bbb/。
我想问一下如何自动重定向a.a.com/bbb/。
ps。8090端口无法访问
对不起,我的英语不好,谢谢。
发布于 2016-12-15 17:26:28
使用proxy_redirect off
location /bbb/ {
proxy_pass 2.2.2.2:8000;
proxy_redirect off;
}proxy_redirect off告诉nginx,如果后端返回一个HTTP重定向,它应该让它保持原样。(默认情况下,nginx会假设后端很愚蠢,并试图变得聪明;如果后端返回一个HTTP重定向,显示"redirect to http://localhost:8000/somewhere",nginx会将其替换为类似于"http://yourowndomain.com/somewhere“的内容,或者,在您的情况下,替换为"http://yourowndomain.com:8090/somewhere”。Django足够聪明,所以nginx不需要做这样的事情。)
https://stackoverflow.com/questions/41159725
复制相似问题