http://backend;和http://backend/;有什么区别呢?

location /service/ {
proxy_pass http://backend;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
}

location /service/ {
proxy_pass http://backend/;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
}
同样访问:http://neverstay.com/service/add.php
前者配置,在后端的机器,收到的是http://neverstay.com/service/add.php
后者配置,在后端的机器,收到的是http://neverstay.com/add.php

如果换成下面这样,会报错:
location ~ ^/(service)/ {
proxy_pass http://backend/;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
}
"proxy_pass" may not have URI part in location given by regular expression, or inside named location, or inside the "if" statement, or inside the "limit_except" block in nginx.conf:

但是,这样就没问题了:
location ~ ^/(service)/ {
proxy_pass http://backend;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
}
把proxy_pass末尾的斜线去掉,就可以了,估计前段时间遇到的后端双层目录也跟这个有关,具体原因待查。。。

相关文章:

  • 2021-08-23
  • 2021-12-19
  • 2021-05-17
  • 2022-12-23
  • 2021-11-05
  • 2021-06-09
  • 2022-02-13
猜你喜欢
  • 2022-02-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-20
  • 2022-12-23
相关资源
相似解决方案