标签:listen web turn chat proxy site blog upgrade inter
server { listen 80; listen 443 ssl 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 = "" ) { return 400; } 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; } }
服务器内部起了2个websocket服务,分别监听8100、8101端口nginx根据访问不同的location,选择代理到那个ws服务商
/websocket/是个内部location,直接访问会报错
参考链接:
http://www.cnblogs.com/weidiao/p/7389744.html
http://www.cnblogs.com/mzsg/p/5623494.html
nginx配置支持https和wss(websocket)协议
标签:listen web turn chat proxy site blog upgrade inter
原文地址:http://www.cnblogs.com/hopelooking/p/7799517.html