关于nginx:nginx配置proxypass后斜杠的访问

1次阅读

共计 442 个字符,预计需要花费 2 分钟才能阅读完成。

1. proxy_pass 斜杠或斜杠后缀结尾不带 location

    1. proxy_pass 后无 ”/” 或 “/xx” 则蕴含 location 中的原串;
  1. proxy_pass 后没有任何 url 门路信息 (比方 “/”, “/xx”) 则反向代理地址会蕴含 location 局部;否则,只会拼接匹配后的残余门路。
location /online/wxapi/
proxy_pass http://localhost:8080/

拜访 “http://www.x.com/online/wxapi/a.html” 会拜访:

http://localhost:8080/a.html

location /online/wxapi/
proxy_pass http://localhost:8080

拜访 “http://www.x.com/online/wxapi/xx.html” 会拜访

http://localhost:8080/online/…

2. 总结:

  • 你加 ”/” 拜访时就不加 location;
  • 你不加 ”/” 拜访时它给你加 location;
正文完
 0