踩坑1:Nginx location 和 proxy_pass 末尾/
问题
序号 | 访问URL | location配置 | proxy_pass配置 | 后端接收的请求 | 备注 |
---|---|---|---|---|---|
1 | http://ibit.tech/user/test.html | /user/ | http://test1/ | /test.html | |
2 | http://ibit.tech/user/test.html | /user/ | http://test1 | /user/test.html | |
3 | http://ibit.tech/user/test.html | /user | http://test1 | /user/test.html | |
4 | http://ibit.tech/user/test.html | /user | http://test1/ | //test.html | |
5 | http://ibit.tech/user/test.html | /user/ | http://test1/haha/ | /haha/test.html | |
6 | http://ibit.tech/user/test.html | /user/ | http://test1/haha | /hahatest.html |
踩坑2:nginx 路径中多个斜杆问题
如果访问 https://ibit.tech//test.html
重定向到 https://ibit.tech/test.html
merge_slashes off;
rewrite (.*)//(.*) $1/$2 permanent;