本文共 1225 字,大约阅读时间需要 4 分钟。
说明:
说明看完,直接开始配置:
nginx.conf中添加以下配置
include testws.conf;
include testwss.conf;
vim testws.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 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" ; } } |
本文转自crazy_charles 51CTO博客,原文链接:http://blog.51cto.com/douya/1874319,如需转载请自行联系原作者