PS: Official documents say that Nginx only supports websocket reverse proxy in versions after 1.3, so if you want to use the function that supports websocket, you must upgrade to versions after 1.3;
There is a problem. Every once in a while, the websocket is disconnected for 1-2 minutes. The service will be restarted or it will automatically recover after 2 minutes.
The service layer architecture is nginx reverse generation tomcat;
Skip the compilation and installation of nginx...
The websocket configuration is as follows:
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";
}
......
}
The problem has been found, please post it;
nginx.conf
proxy_read_timeout 86400;
include http://www.test.com
keepalive 64;