亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

nginx - django redirect to relative path
黃舟
黃舟 2017-05-16 17:24:35
0
1
946

The deployment environment is Nginx gunicorn Django

Nginx configuration is as follows

location /app1 {
        rewrite ^/app1/(.*)$ / break;
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_redirect off;
        proxy_pass http://11.11.11.1:8001;
}
location /app2 {
        rewrite ^/app2/(.*)$ / break;
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_redirect off;
        proxy_pass http://11.11.11.1:8002;
}

app1 and app2 are different applications. The following are the problems encountered

When accessing /app1/test, Django will add slash at the end and redirect. The problem is that it will redirect /test/ instead of / app1/test/
When accessing /app1/admin, it will be redirected to /admin/login/?next=/admin/.

In my own program, for example, when Oauth authentication requires a redirection URI, I think of passing $http_host/app1 through X-host## when using Nginx proxy. # Passed to the backend Django, and then get the real URI.

But the redirection inside Django doesn’t know how to pass the real URI and path, or it can use relative paths instead of absolute paths when redirecting inside Django.

黃舟
黃舟

人生最曼妙的風景,竟是內(nèi)心的淡定與從容!

reply all(1)
洪濤

https://docs.djangoproject.com/en/dev/ref/settings/#use-x-forwarded-ho...

https://docs.djangoproject.com/en/1.8/ref/settings/#force-script-name

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template