nginx中proxy_pass最后到底要不要加/

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012949658/article/details/86605805

nginx中proxy_pass最后到底要不要加/

在nginx中配置proxy_pass代理转发时,如果在proxy_pass后面的url最后加/,表示绝对路径;
如果没有/,表示相对路径,把匹配的路径部分也给代理走,具体示例如下:

  • url最后带/
location /test/ {
    proxy_pass http://$upstream/;
}

请求地址http://$domainname:$port/proxy/$resource,经过nginx代理之后转发地址为http://$upstream/$resource。

  • url最后不带/
location /test/ {
    proxy_pass http://$upstream;
}

请求地址http://$domainname:$port/proxy/$resource,经过nginx代理之后转发地址为http://$upstream/proxy/$resource。

参考资料:https://blog.csdn.net/aerchi/article/details/84968106

猜你喜欢

转载自blog.csdn.net/u012949658/article/details/86605805
今日推荐