标签:nginx配置文件 host VID set web 无法找到 mic socket http
前几天开发了一个功能,使用websocket向前台发送消息,与前端联调时一切正常,但是发布到环境出现如下报错:

发现404,无法找到连接,突然想到环境上是走nginx代理的,应该是nginx没有配置代理,于是nginx配置如下:
location /ctm01expvideo-web/ {
        proxy_set_header   Host             $http_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 Upgrade "websocket";
        //新添加
        proxy_set_header Connection "upgrade";
        proxy_pass http://10.194.98.123:36099/ctm01expvideo-web/;
}
上面的配置可以使代理端口支持websocket协议,重启nginx后404报错消失,但是又出现如下报错:

查阅资料后发现是配置有问题,重新修改nginx配置文件:
location /ctm01expvideo-web/ {
        proxy_set_header   Host             $http_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 Upgrade "websocket";
        //新添加
        proxy_set_header Connection "upgrade";
        //新添加
        proxy_http_version 1.1;
        proxy_pass http://10.194.98.123:36099/ctm01expvideo-web/;
}
恢复正常。
标签:nginx配置文件 host VID set web 无法找到 mic socket http
原文地址:https://www.cnblogs.com/jxxblogs/p/12890330.html