location /tobaidu {
proxy_pass http://127.0.0.1:8087;
}
curl http://127.0.0.1/tobaidu
http://127.0.0.1:8087/tobaidu
curl http://127.0.0.1/tobaidu/
http://127.0.0.1:8087/tobaidu/
curl http://127.0.0.1/tobaidu/xxxx
http://127.0.0.1:8087/tobaidu/xxxx
location /tobaidu {
proxy_pass http://127.0.0.1:8087/define;
}
curl http://127.0.0.1/tobaidu
http://127.0.0.1:8087/define
curl http://127.0.0.1/tobaidu/
http://127.0.0.1:8087/define/
curl http://127.0.0.1/tobaidu/xxxx
http://127.0.0.1:8087/define/xxxx
location /tobaidu/ {
proxy_pass http://127.0.0.1:8087;
}
curl http://127.0.0.1/tobaidu
重定向到http://127.0.0.1/tobaidu/
curl http://127.0.0.1/tobaidu/
http://127.0.0.1:8087/tobaidu/
curl http://127.0.0.1/tobaidu/xxxx
http://127.0.0.1:8087/tobaidu/xxxx
location /tobaidu/ {
proxy_pass http://127.0.0.1:8087/define;
}
curl http://127.0.0.1/tobaidu
重定向到http://127.0.0.1/tobaidu/
curl http://127.0.0.1/tobaidu/
http://127.0.0.1:8087/define
curl http://127.0.0.1/tobaidu/xxxx
http://127.0.0.1:8087/definexxxx
location /tobaidu {
proxy_pass http://127.0.0.1:8087/;
}
curl http://127.0.0.1/tobaidu
http://127.0.0.1:8087/
curl http://127.0.0.1/tobaidu/
http://127.0.0.1:8087//
curl http://127.0.0.1/tobaidu/xxxx
http://127.0.0.1:8087//xxxx
location /tobaidu {
proxy_pass http://127.0.0.1:8087/define/;
}
curl http://127.0.0.1/tobaidu
http://127.0.0.1:8087/define/
curl http://127.0.0.1/tobaidu/
http://127.0.0.1:8087/define//
curl http://127.0.0.1/tobaidu/xxxx
http://127.0.0.1:8087/define//xxxx
location /tobaidu/ {
proxy_pass http://127.0.0.1:8087/;
}
curl http://127.0.0.1/tobaidu
重定向到http://127.0.0.1/tobaidu/
curl http://127.0.0.1/tobaidu/
http://127.0.0.1:8087/
curl http://127.0.0.1/tobaidu/xxxx
http://127.0.0.1:8087/xxxx
location /tobaidu/ {
proxy_pass http://127.0.0.1:8087/define/;
}
curl http://127.0.0.1/tobaidu
重定向到http://127.0.0.1/tobaidu/
curl http://127.0.0.1/tobaidu/
http://127.0.0.1:8087/define/
curl http://127.0.0.1/tobaidu/xxxx
http://127.0.0.1:8087/define/xxxx
URL符合 protocol://ip:port 同时结尾不加/,则nginx会代理匹配路径部分,否则不代理匹配路径,同时自动添加不匹配路径”部分”,比如/tobaidu/xxxx
的/xxxx
部分
测试7为常用的反向代理