nginx反向代理websocket
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx反向代理websocket相关的知识,希望对你有一定的参考价值。
说明:http://www.oschina.net/translate/websocket-nginx
说明看完,直接开始配置:
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"; } }
本文出自 “crazy_sir” 博客,请务必保留此出处http://douya.blog.51cto.com/6173221/1874319
以上是关于nginx反向代理websocket的主要内容,如果未能解决你的问题,请参考以下文章