The local test is normal, but the online test is always disconnected after a while...
The https protocol has been added online, so the links on the page must also be ssl
Websocket link address ws://ws.xxx.com
changed fromwss://ws.xxx.com
The initial http
configuration is as follows:
server {
listen 80;
server_name ws.xxx.com;
location / {
proxy_pass http://127.0.0.1:8110;
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 Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
client_max_body_size 1000m;
proxy_read_timeout 360s;
}
}
https
After upgrading to ssl
the configuration:
server {
listen 443 ssl;
server_name ws.xxx.com;
ssl_certificate /usr/local/nginx/ws.xxx.com.crt;
ssl_certificate_key /usr/local/nginx/ws.xxx.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:8110;
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 Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
client_max_body_size 1000m;
}
}
ssl
When adding a proxy to Nginx online , there is no settingproxy_read_timeout
The correct approach should be to proxy_read_timeout
configure a time greater than Websocket
the heartbeat time
Reference:
Nginx Proxy Configuration
Nginx Reconnection Time