0
点赞
收藏
分享

微信扫一扫

用nginx做负载时访问时提示{“result”:"host path error"}解决方案

最近在工作中,有小伙伴在用NG做负载时,配置完后发现{“result”:"host path error"},这个提示,处理方法很简单:

用nginx做负载时访问时提示{“result”:"host path error"}解决方案_重启

此时直接在服务器上curl这个网址也是这个提示:

curl http://10.0.157.47/

用nginx做负载时访问时提示{“result”:"host path error"}解决方案_nginx_02

处理方法如下: 

注释: proxy_set_header X-Forwarded-Proto $scheme;

添加以下三行:

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

proxy_set_header X-NginX-Proxy true;

server {
    listen 80;
    server_name 10.0.157.47;
 
    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        # proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_pass http://xxxxxx.xxx.com;
    }
}

用nginx做负载时访问时提示{“result”:"host path error"}解决方案_服务器_03

然后重启nginx服务:

用nginx做负载时访问时提示{“result”:"host path error"}解决方案_重启_04

此时直接在服务器上curl这个网址就正常了:

用nginx做负载时访问时提示{“result”:"host path error"}解决方案_服务器_05

之后让客户浏览器访问也可正常访问(这里由于是客户的生产环境,电脑都截图都带有水印[名字+工号],就不贴客户浏览器访问的截图了)


举报

相关推荐

0 条评论