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" ; } |
作者:怎么了
欢迎任何形式的转载,但请务必注明出处。
限于本人水平,如果文章和代码有表述不当之处,还请不吝赐教。
分类:
Java
标签:
webSoecket
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构