nginx reverse generation websocket disconnected
过去多啦不再A梦
过去多啦不再A梦 2017-05-16 17:25:51
0
1
739

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";
        }

        ......
}
过去多啦不再A梦
过去多啦不再A梦

reply all(1)
大家讲道理

The problem has been found, please post it;

nginx.conf
proxy_read_timeout 86400;

include http://www.test.com
keepalive 64;

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!