部署项目后 websocket 连接失效问题

项目本地测试运行没有问题

但是把项目部署到云服务器上以后,死活连接不上去。
最后找到原因了,是 Nginx 配置文件有问题。
修改为这个,问题解决。

 location / {
      proxy_pass http://127.0.0.1:8080;
      proxy_set_header Host $host:80;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
 }
发布了39 篇原创文章 · 获赞 20 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/cong____cong/article/details/104279636