nginx反向代理ws和wss出现问题
看你error日志应该和后端的服务有关,我们是这样配置的,你参考一下 websocket技术,websocket的反向代理实现比较特殊,具体配置如下:
在nginx的主配置文件的http段的作用域中添加以下配置:
#vim /etc/nginx/nginx.conf
map $http_upgrade $connection_upgrade { default upgrade; '' close; }
编写websocket的反向代理设置
#vim /etc/nginx/conf.d/k2wrapper.conf
upstream k2wrapperserver { hash $remote_addr consistent; server 192.168.6.50:31002; server 192.168.6.51:31002; }
server { listen 8182; server_name xxxxxxxx.cn;
location / { proxy_pass http://k2wrapperserver/; proxy_set_header Host $host:$server_port; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; } }
#使用阿里云的你竟然还不知道这个?#
赞0
踩0