做用域: locationhtml
测试机: 172.16.200.160 my.yemao.comapi
172.16.200.143 test.yemao.com浏览器
注:在proxy_pass中的代理url后加上/,代理转发的url中就不会带上location中匹配路径;服务器
咱们访问 http://my.yemao.com/proxy/index.html,实际上是访问到了 http://test.yemao.com/index.html测试
咱们访问 http://my.yemao.com/proxy/index.htmlurl
upstream backend { server backend1.example.com weight=5; server backend2.example.com:8080; server unix:/tmp/backend3; server backup1.example.com:8080 backup; server backup2.example.com:8080 backup; } server { location / { proxy_pass http://backend/user/pub/api/; } }