Nginx配置proxy_pass

源:http://dmouse.iteye.com/blog/1880474
评:
nginx配置proxy_pass,需要注意转发的路径配置

1、location /test/ {
                proxy_pass http://t6:8300;
     }

2、location /test/ {
                proxy_pass http://t6:8300/;
     }

上面两种配置,区别只在于proxy_pass转发的路径后是否带 “/”

针对情况2,如果访问url = http://server/test/test.jsp,则被nginx代理后,请求路径会变为 http://proxy_pass/test.jsp,直接访问server的根资源

针对情况1,如果访问url = http://server/test/test.jsp,则被nginx代理后,请求路径会便问http://proxy_pass/test/test.jsp,将test/ 作为根路径,请求test/路径下的资源

猜你喜欢

转载自mauersu.iteye.com/blog/2162020