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. 小程序怎么加外鏈,語句怎么寫!求救新手,開文檔沒發現2. javascript - ...mapGetters和...mapState獲取到的state,怎么拿來在methods中操作?3. python - linux怎么在每天的凌晨2點執行一次這個log.py文件4. javascript - 在 vue里面用import引入js文件,結果為undefined5. 如何分別在Windows下用Winform項模板+C#,在MacOSX下用Cocos Application項目模板+Objective-C實現一個制作游戲的空的黑窗口?6. Java反射問題:為什么android.os.Message的recycleUnchecked方法不能通過反射獲取到?7. php如何獲取訪問者路由器的mac地址8. git - 使用淘寶npm安裝hexo出現問題?9. php - 微信開發驗證服務器有效性10. [python2]local variable referenced before assignment問題
