Server {Listen80; Listen443SSL HTTP2; server_name lyz810.com; Root/website/lyz810-main; Ssl_certificate Certificate/lyz810.com.CRT; Ssl_certificate_key Certificate/lyz810.com.Key; Location/websocket/{internal; if($http _sec_websocket_protocol= "" ) { return400; } Proxy_pass http://127.0.0.1: $arg _port;Proxy_http_version 1.1; Proxy_set_header X-client-ip$remote _addr; Proxy_set_header Upgrade$http _upgrade; Proxy_set_header Connection"Upgrade"; Proxy_read_timeout 300s; } Location/Chatroom {rewrite. */websocket/?port=8100; } Location/Chatrobot {rewrite. */WEBSOCKET/?PORT=8101; }}
Server Internal 2 websocket services, respectively, monitoring 8100, 8101 Port Nginx based on access to different location, select Agent to the WS service Provider
/websocket/is an internal location where direct access will be an error.
Reference Links:
Http://www.cnblogs.com/weidiao/p/7389744.html
Http://www.cnblogs.com/mzsg/p/5623494.html
Nginx configuration supports HTTPS and WSS (websocket) protocol