Different behavour of “location” and “proxy_pass” on nginx x-accel-redirect

核能气质少年 提交于 2019-12-02 03:13:28

The proxy_pass directive can perform an aliasing function, but only if an optional URI is provided.

location ^~ /to_proxy/ {
    internal;
    proxy_pass http://myproxy:5000/;
}

To make the alias mapping work correctly, a trailing / is also added to the location parameter.

See this document for details.

If the trailing / on the location parameter causes problems, you can use a rewrite ... break instead:

location ^~ /to_proxy {
    internal;
    rewrite ^/to_proxy(?:/(.*))?$ /$1 break;
    proxy_pass http://myproxy:5000;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!