nginx 反代 websocket 斷線
問題描述
PS:官方文檔說 Nginx 在 1.3 以后的版本才支持 websocket 反向代理,所以要想使用支持 websocket 的功能,必須升級到 1.3 以后的版本;
現出現一個問題每隔一段時間websocket斷線1-2分鐘,重啟服務或者2分鐘后會自動恢復,服務層架構是nginx反代tomcat;
nginx的編譯安裝略過......
websocket配置如下:
http { ...... #websocket 需要加下這個 map $http_upgrade $connection_upgrade { default upgrade; ’’ close; } ......}server {......location ^~ /websocket {proxy_pass http://www.test.com;proxy_redirect off;proxy_set_header X-Real-IP $remote_addr;proxy_set_header Host $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection 'upgrade';}......}
問題解答
回答1:已經找到問題了,結貼;
nginx.confproxy_read_timeout 86400;
include http://www.test.comkeepalive 64;
相關文章:
1. python - 獲取到的數據生成新的mysql表2. javascript - js 對中文進行MD5加密和python結果不一樣。3. mysql里的大表用mycat做水平拆分,是不是要先手動分好,再配置mycat4. window下mysql中文亂碼怎么解決??5. sass - gem install compass 使用淘寶 Ruby 安裝失敗,出現 4046. python - (初學者)代碼運行不起來,求指導,謝謝!7. 為啥不用HBuilder?8. python - flask sqlalchemy signals 無法觸發9. python的文件讀寫問題?10. 為什么python中實例檢查推薦使用isinstance而不是type?
