nginx中location与proxy_pass的斜杠问题
nginx中location与proxy_pass的斜杠问题文章目录nginx中location与proxy_pass的斜杠问题proxy_pass类型配置例子proxy_pass类型不带URI,只包含IP和端口:proxy_pass http://192.168.200.227:8080带URI(包括单斜杠):proxy_pass http://192.168.200.227:8080/或pro
·
nginx中location与proxy_pass的斜杠问题
proxy_pass类型
不带URI,只包含IP和端口:proxy_pass http://192.168.200.227:8080
带URI(包括单斜杠):proxy_pass http://192.168.200.227:8080/,
proxy_pass http://192.168.200.227:8080/aaa,proxy_pass http://192.168.200.227:8080/aaa/等情况
配置例子
- 不带URI,只包含IP和端口,将所有URI拼入proxy_pass后面
# 访问地址:http://192.168.200.227:80/proxy/api/test
location /proxy/ {
proxy_pass http://192.168.200.227:8080;
}
# 1️⃣ 实际地址:http://192.168.200.227:8080/proxy/api/test
location /proxy {
proxy_pass http://192.168.200.227:8080;
}
# 2️⃣ 实际地址:http://192.168.200.227:8080/proxy/api/test
- 带URI(包括单斜杠),将排除location后的URI拼入proxy_pass后面
# 访问地址:http://192.168.200.227:80/proxy/api/test
location /proxy/ {
proxy_pass http://192.168.200.227:8080/;
}
# 3️⃣ 实际地址:http://192.168.200.227:8080/api/test
location /proxy {
proxy_pass http://192.168.200.227:8080/;
}
# 4️⃣ 实际地址:http://192.168.200.227:8080//api/test
location /proxy/ {
proxy_pass http://192.168.200.227:8080/test/;
}
# 5️⃣ 实际地址:http://192.168.200.227:8080/test/api/test
location /proxy {
proxy_pass http://192.168.200.227:8080/test/;
}
# 6️⃣ 实际地址:http://192.168.200.227:8080/test//api/test
location /proxy/ {
proxy_pass http://192.168.200.227:8080/test;
}
# 7️⃣ 实际地址:http://192.168.200.227:8080/testapi/test
location /proxy {
proxy_pass http://192.168.200.227:8080/test;
}
# 8️⃣ 实际地址:http://192.168.200.227:8080/test/api/test
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)