本文为joshua317原创文章,转载请注明:转载自joshua317博客 https://www.joshua317.com/article/179
在nginx中配置proxy_pass代理转发时,如果在proxy_pass后面的url加/,表示绝对根路径;如果没有/,表示相对路径,把匹配的路径部分也给代理走。
假设下面四种情况分别用 http://192.168.1.1/proxy/test.html 进行访问。
http://192.168.4.173:8084/test.htmllocation /proxy/ {
proxy_pass http://192.168.4.173:8084/;
}注意:proxy后面以及 192.168.4.173:8084后面都有/
http://192.168.4.173:8084/proxy/test.htmllocation /proxy/ {
proxy_pass http://192.168.4.173:8084;
}注意:192.168.4.173:8084后面是没有/的
http://192.168.4.173:8084/gateway/test.htmllocation /proxy/ {
proxy_pass http://192.168.4.173:8084/gateway/;
}注意:192.168.4.173:8084/gateway后面是有/的
http://192.168.4.173:8084/gatewaytest.htmllocation /proxy/ {
proxy_pass http://192.168.4.173:8084/gateway;
}注意:192.168.4.173:8084/gateway后面是没有/的
本文为joshua317原创文章,转载请注明:转载自joshua317博客 https://www.joshua317.com/article/179