nginx配置webSocket转发

一、连接webSocket后台报Handshake failed due to invalid Upgrade header: null 解决方案

解决办法:在 nginx的location 中添加以下代码:

1
2
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection  "upgrade";

  例如:

1
2
3
4
5
6
7
8
9
10
11
location /strong_learning_police_czys_yanshi/ {
            proxy_pass http://192.168.0.247:6610/strong_learning_police_czys_yanshi/;
            proxy_set_header  Host  $host;
            proxy_set_header  X-Real-IP  $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
            client_max_body_size 1000M;
            proxy_read_timeout 1800s;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        }

  

作者:怎么了
欢迎任何形式的转载,但请务必注明出处。
限于本人水平,如果文章和代码有表述不当之处,还请不吝赐教。

posted @   怎么了~  阅读(1954)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示