2016-02-11 103 views
4

我試圖用nginx 1.9.11代理位置到websocket上游。以下是配置摘錄:2分鐘後Nginx websocket代理斷開

upstream autocloud_dispatcher { 
    server 127.0.0.1:4000 fail_timeout=0; 
} 

server { 
    ..... 
    location /ws { 
    proxy_pass http://autocloud_dispatcher; 
    proxy_http_version 1.1; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
    proxy_connect_timeout 7d; 
    proxy_send_timeout 7d; 
    proxy_read_timeout 7d; 
    } 
} 

除此之外,我每隔90秒發送一次來自備份的ping消息。但連接每2分鐘仍然斷開連接。 nginx中的其他一些默認設置爲120s的設置?

回答

1

在幾秒鐘內設置超時時間幫我,我的配置

location ~ /wss/(.*) { 
    proxy_pass http://127.0.0.1:$1; 
    proxy_http_version 1.1; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
    proxy_set_header Host $host; 

    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Proto https; 

    proxy_read_timeout 36000s; 

    proxy_redirect off; 
}