原创

关于NGINX的代理转发后缀带不带斜杠的记录


请求地址: http://www.test.com/api/param1

1、location不带"/",proxy_pass不带"/"

location /api {
    proxy_pass http://www.rlt.com;
}

实际请求:http://www.rlt.com/api/param1

2、location带"/",proxy_pass不带"/"

location /api/ {
    proxy_pass http://www.rlt.com;
}

实际请求:http://www.rlt.com/api/param1

3、location不带"/",proxy_pass带"/"

location /api {
    proxy_pass http://www.rlt.com/;
}

实际请求:http://www.rlt.com/param1

4、location带"/",proxy_pass带"/"

location /api/ {
    proxy_pass http://www.rlt.com/;
}

实际请求:http://www.rlt.com/param1

5、location不带"/",proxy_pass带"/api"

location /api {
    proxy_pass http://www.rlt.com/api;
}

实际请求:http://www.rlt.com/api/param1

6、location带"/",proxy_pass带"/api"

location /api/ {
    proxy_pass http://www.rlt.com/api;
}

实际请求:http://www.rlt.com/apiparam1

7、location不带"/",proxy_pass带"/api/"

location /api {
    proxy_pass http://www.rlt.com/api/;
}

实际请求:http://www.rlt.com/api/param1

8、location带"/",proxy_pass带"/api/"

location /api/ {
    proxy_pass http://www.rlt.com/api/;
}

实际请求:http://www.rlt.com/api/param1

Nginx
  • 作者:一介闲人(联系作者)
  • 发表时间: 2024-07-03 17:17
  • 版权声明:原创-转载需保持署名
  • 公众号转载:请在文末添加本文链接
  • 评论