关于配置websocket,nginx转发https至wss问题

在本地测试通过的socket,再放到现在的有nginx代理之后发现会报:failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED这样的错误。分析原因可能nginx代理https的时候wss不能进行转发导致链接不上。

解决办法:

    打开nginx.conf文件,在配置ssl证书 /location下面添加: 

     proxy_http_version 1.1;

     proxy_set_header Upgrade $http_upgrade;

     proxy_set_header Connection "upgrade";

这样当代理转发https协议握手的时候同事也能转发给wss协议进行握手

posted @ 2018-12-18 11:33  dream_fly_info  阅读(4831)  评论(0编辑  收藏  举报