栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用Nginx的流星WebSocket握手错误400

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用Nginx的流星WebSocket握手错误400

WebSocket速度很快,您不必(也不应该)禁用它们。

导致此错误的真正原因是Webfactions使用nginx,并且nginx配置不正确。通过设置和,以下是正确配置nginx代理WebSocket请求的方法:

proxy_set_headerUpgrade $http_upgrade;``proxy_set_header Connection $connection_upgrade;

# we're in the http context heremap $http_upgrade $connection_upgrade {  default upgrade;  ''      close;}# the Meteor / Node.js app serverserver {  server_name yourdomain.com;  access_log /etc/nginx/logs/yourapp.access;  error_log /etc/nginx/logs/yourapp.error error;  location / {    proxy_pass http://localhost:3000;    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    proxy_set_header Host $host;  # pass the host header - http://wiki.nginx.org/HttpProxyModule#proxy_pass    proxy_http_version 1.1;  # recommended with keepalive connections - http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_http_version    # WebSocket proxying - from http://nginx.org/en/docs/http/websocket.html    proxy_set_header Upgrade $http_upgrade;    proxy_set_header Connection $connection_upgrade;  }}

这是基于David Weldon的nginxconfig的改进的nginx配置。安德鲁·毛(Andrew
Mao)已经达到了非常相似的配置。

请记住,还要将HTTP_FORWARDED_COUNT环境变量设置为应用程序前面的代理数量(通常为1)。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/406587.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号