Nginx代理如何处理内部重定向

时间:2017-07-05 20:13:10

标签: nginx proxy reverse-proxy nginx-location

我有一个问题需要了解nginx proxy_pass在URL重写后如何处理重定向。

我拥有的内容localhost:8080/foo/log会自动重定向到localhost:8080/foo/login。输入正确的凭据后,它将重定向回localhost:8080/foo/log

localhost:8080/foo/log -----> localhost:8080/foo/login

我有一个nginx代理服务器,可以通过以下配置将我的网址从localhost:8080/foo/log更改为localhost/web/foo/log

server {
    listen 80;
    listen [::]:80;

    server_name localhost;

    root /var/www/html;
    index index.html;

    location /web/foo {
        proxy_pass http://localhost:8080/;
        rewrite ^/web/foo(.*) /foo$1 break;
    }

    location /web/bar {
        proxy_pass http://localhost:8081/;
        rewrite ^/web/bar(.*) /bar$1 break;
    }
}   

使用此代理配置,我可以在不启用登录重定向的情况下从localhost/web/foo/log看到localhost:8080/foo/log代理。如果我启用了登录功能,我将始终获得localhost/web/foofoo/login

我想知道如何从localhost/web/foo/login获取localhost:8080/foo/login代理?

0 个答案:

没有答案
相关问题