nginx 署理 web socket 报错“WebSocket is already in CLOSING or CLOSED state.”

在生产环境中需要使用 nginx 署理 websocket ,根据正常设置之后发现浏览器一直提醒 “WebSocket is already in CLOSING or CLOSED state.”

这是由于 nginx 在署理需要添加如下两个参数

           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection "upgrade";

加上如下参数正常