单体nginx集群
版本号:
v3.4.1
前端版本:vue3版?还是 vue2版?
vue2
问题描述:
想通过后端集群,nginx负载多个后端,可是前端会提示websoket连接失败,是不是Redis的什么没共享?单体的时候直接连接单个后端websoket就能连接成功
截图&代码:

友情提示(为了提高issue处理效率):
- 未按格式要求发帖,会被直接删掉;
- 描述过于简单或模糊,导致无法处理的,会被直接删掉;
- 请自己初判问题描述是否清楚,是否方便我们调查处理;
- 针对问题请说明是Online在线功能(需说明用的主题模板),还是生成的代码功能;
兄弟,如果你后台用 nginx 代理的话,前台访问后端 VUE_APP_API_BASE_URL 配置的是代理地址,那么你后台拿边也要针对 websocket 配置代理的,因为前端连接 ws 的时候也是 获取 VUE_APP_API_BASE_URL 去连接的。
具体应该怎么配置呢?老哥教我
www.baidu.com
@3509282792
www.baidu.com 这个回复我竟无言疑问、、、
@3509282792
#服务器集群 upstream tomcat { least_conn; server 127.0.0.1:8081 ; server 127.0.0.1:8082 ;#可以在这里加权重 } #gzip on;
server { listen 80; server_name localhost;
gzip config
gzip on; gzip_min_length 1k; gzip_comp_level 9; gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; gzip_vary on; gzip_disable "MSIE [1-6].";
#charset koi8-r;
#access_log logs/host.access.log main;
location ^~ /huael-boot { #root html; #index index.html index.htm; proxy_pass http://tomcat/huael-boot; proxy_redirect default; proxy_set_header Host 127.0.0.1; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
#解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题 location / { root html; index index.html index.htm; if (!-e $request_filename) { rewrite ^(.*)$ /index.html?s=$1 last; break; } }
}
@xiaolinVV 教我嘛,我试试
解决了,果然是要websocket 也代理