1、假设server_name为www.xxx.com
当请求http://www.xxx.com/aming/a.html的时候,以上示例分别访问的结果是
示例1:
location /amazing/ {
proxy_pass http://192.168.1.10;
...
}
结果1:http://192.168.1.10/aming/a.html
示例2:
location /amazing/ {
proxy_pass http://192.168.1.10/;
...
}
结果2:http://192.168.1.10/a.html
示例3:
location /amazing/ {
proxy_pass http://192.168.1.10/linux/;
...
}
结果3:http://192.168.1.10/linux/a.html
示例4:
location /amazing/ {
proxy_pass http://192.168.1.10/linux;
...
}
结果4:http://192.168.1.10/linuxa.html
2、在配置 nacos 域名访问时,一开始这样配置的
location / {
proxy_pass http://192.168.1.10/nacos;
...
}
然后访问域名,就报 “将您重定向的次数过多” 到错误。
/ 后面的nacos是一个目录,后面应该用 / 结尾
location / {
proxy_pass http://192.168.1.10/nacos/;
...
}
3、建议所有的 proxy_pass 后的url都以“/”结尾。
proxy_pass http://192.168.1.10/linux/;
Nginx Proxy Pass 配置详解
本文详细解析了 Nginx 中 proxy_pass 的不同配置方式及其产生的效果,包括路径结尾符号对代理请求的影响,并指出正确的配置方法避免错误。
9698

被折叠的 条评论
为什么被折叠?



