SingR 部署后顯示:WebSocket connection to failed: Error during WebSocket handshake: Unexpected response code: 200


部署到Linux后,出現問題:

WebSocket connection to failed: Error during WebSocket handshake: Unexpected response code: 200

 

原因是服務器使用Nginx不支持websocket,但Nginx可用代理Websocket連接,需要做如下配置:

location / {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

  

但我們修改后會出現問題,我么之前正常的請求,都變成了400 Bad Request

 

我們想方法變通下,獨立出SingR的請求配置

 

location / {
  proxy_pass http://backend;
  proxy_http_version 1.1;
}

location /chatHub {
  proxy_pass http://backend;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
}

  

這樣就可用了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM