
location和proxy_pass的是否以斜杠结尾
一、 location 是否以“/”结尾
在 ngnix 中 location 进行的是模糊匹配
没有“/”结尾时,location/abc/def 可以匹配 /abc/defghi 请求,也可以匹配 /abc/def/ghi 等
而有“/”结尾时,location/abc/def/ 不能匹配 /abc/defghi 请求,只能匹配 /abc/def/anything 这样的请求
二、proxy_pass 代理规则(是否以“/”结尾)
(1)配置 proxy_pass 时,当在后面的 url 加上了 /,相当于是绝对路径,则 Nginx 不会把 location 中匹
配的路径部分加入代理 uri。
比如下面配置,我们访问 http://IP/proxy/test.html,最终代理到 URL 是 http://127.0.0.1/test.html

(2)如果配置 proxy_pass 时,后面没有 /,Nginx 则会把匹配的路径部分加入代理 uri。
比如下面配置,我们访问 http://IP/proxy/test.html,最终代理到 URL 是 http://127.0.0.1/proxy/test.ht
ml
