nginx 之 proxy_pass详解html
在nginx中配置proxy_pass代理转发时,若是在proxy_pass后面的url加/,表示绝对根路径;若是没有/,表示相对路径,把匹配的路径部分也给代理走。nginx
假设下面四种状况分别用 http://192.168.1.1/proxy/test.html 进行访问。url
第一种: location /proxy/ { proxy_pass http://127.0.0.1/; } 代理到URL:http://127.0.0.1/test.html代理
第二种(相对于第一种,最后少一个 / ) location /proxy/ { proxy_pass http://127.0.0.1; } 代理到URL:http://127.0.0.1/proxy/test.htmlhtm
第三种: location /proxy/ { proxy_pass http://127.0.0.1/aaa/; } 代理到URL:http://127.0.0.1/aaa/test.htmlget
第四种(相对于第三种,最后少一个 / ) location /proxy/ { proxy_pass http://127.0.0.1/aaa; } 代理到URL:http://127.0.0.1/aaatest.htmlio