server {
listen 80;
server_name localhost;
location /api1/ {
proxy_pass http://localhost:8080;
}
# http://localhost/api1/xxx -> http://localhost:8080/api1/xxx
# 如果proxy_pass路径是根路径且后面没有/,而location路径后面有/,则实际生成的请求路径是proxy_pass路径后先拼接location路径,再拼接实际请求路径中location路径后面的路径
location /api2/ {
proxy_pass http://localhost:8080/;
}
# http://localhost/api2/xxx -> http://localhost:8080/xxx
# 如果proxy_pass路径是根路径且后面有/,而location路径后面有/,则实际生成的请求的路径是proxy_pass路径后直接拼接实际请求路径中location路径后面的路径
location /api3 {
proxy_pass http://localhost:8080;
}
# http://localhost/api3/xxx -> http://localhost:8080/api3/xxx
# 如果proxy_pass路径是根路径且后面没有/,而location路径后面也没有/,则实际生成的请求的路径是proxy_pass路径后先拼接location路径,再拼接实际请求路径中location路径后面的部分
location /api4 {
proxy_pass http://localhost:8080/;
}
# http://localhost/api4/xxx -&
nginx资源转发路径斜杠问题
最新推荐文章于 2023-07-15 08:00:00 发布