Description: Http://www.oschina.net/translate/websocket-nginx
After reading the instructions, start the configuration directly:
Add the following configuration in nginx.conf
Include testws.conf;
Include testwss.conf;
Vim testws.conf
Map $http _upgrade $connection _upgrade {default upgrade; ' Close;} Upstream WebSocket {server 10.0.0.x:6020;} server {server_name yourdomain; Listen 80; Access_log Logs/xx.access.log Main; Location/{Proxy_pass Http://websocket; Proxy_http_version 1.1; Proxy_set_header Upgrade $http _upgrade; Proxy_set_header Connection "Upgrade"; }}
Vim testwss.conf
map $http _upgrade $connection _upgrade { default upgrade; ' close;} upstream websocket1 { server 10.0.0.x:6020;} server { server_name yourdomain; listen 443; ssl on; ssl_certificate xxxx.crt; ssl_certificate_key xxxx.key; ssl_session_timeout 5m; ssl_protocols tlsv1 tlsv1.1 tlsv1.2; ssl_ciphers high:! rc4:! md5:!anull:!enull:! Null:! Dh:! edh:! Exp:+medium; ssl_prefer_server_ciphers on; access_log logs/xx.access.log main; location / { proxy_pass http://websocket1; proxy_http_version 1.1; proxy_set_header Upgrade $http _upgrade; proxy_set_header Connection "Upgrade"; }}
This article is from the "Crazy_sir" blog, make sure to keep this source http://douya.blog.51cto.com/6173221/1874319
Nginx Reverse proxy WebSocket