假设访问路径的 /pss/bill.html
加/的情况
location /pss/ {
proxy_pass http://127.0.0.1:18081/;
}
被访问的真实访问路径 http://127.0.0.1:18081/bill.html
不加/的情况
location /pss/ {
proxy_pass http://127.0.0.1:18081;
}
被访问的真实路径 http://127.0.0.1:18081/pss/bill.html
本文详细探讨了在Nginx配置中,location块内proxy_pass指令后是否添加'/'对实际访问路径的影响。当添加'/'时,请求将被转发到'http://127.0.0.1:18081/bill.html',而不添加'/'则转发至'http://127.0.0.1:18081/pss/bill.html'。理解这一区别对于精确控制服务路由至关重要。
假设访问路径的 /pss/bill.html
加/的情况
location /pss/ {
proxy_pass http://127.0.0.1:18081/;
}
被访问的真实访问路径 http://127.0.0.1:18081/bill.html
不加/的情况
location /pss/ {
proxy_pass http://127.0.0.1:18081;
}
被访问的真实路径 http://127.0.0.1:18081/pss/bill.html
1388
1644
1279

被折叠的 条评论
为什么被折叠?