加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

Meteor,WebSocket,Nginx 502错误

发布时间:2020-12-13 21:01:48 所属栏目:Nginx 来源:网络整理
导读:我们正试图在Nginx后面的Debian服务器上运行Meteor应用程序.应用程序正在运行,但是在http:// url / sockjs?info?cb = [random_string]的GET请求返回502 Bad Gateway. Nginx配置如下设置: # this section is needed to proxy web-socket connectionsmap $

我们正试图在Nginx后面的Debian服务器上运行Meteor应用程序.应用程序正在运行,但是在http:// url / sockjs?info?cb = [random_string]的GET请求返回502 Bad Gateway.

Nginx配置如下设置:

# this section is needed to proxy web-socket connections
map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

upstream app_server {
    server 127.0.0.1:3000; # for a web port socket (we'll use this first)
    # server unix:/var/run/app/app.sock;
}

server {
    listen       80;
    server_name  app_server.com;

    charset utf-8;
    client_max_body_size 75M;

    access_log  /var/log/nginx/app.access.log;
    error_log  /var/log/nginx/app.error.log;

    location / {
        proxy_pass http://app_server;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header X-Forwarded-For $remote_addr; # preserve client IP
        proxy_read_timeout 60s;
        keepalive_timeout 65;
        proxy_redirect off;
        # the root path (/) MUST NOT be cached
        if ($uri != '/') {
            expires 30d;
        }
    }
}

我们已经尝试了各种配置,无法确定故障所在. Meteor WebSocket handshake error 400 with nginx的解决方案也无效.

编辑:尝试在recommended nginx configuration for meteor找到以下配置,它仍然返回502.

编辑:当不从Meteor CFS获取图像时,应用程序正常工作,Meteor CFS用于通过管理仪表板存储上传的图像.加载图像时,对域/ sockjs / img_location / cb / xhr_send的POST会导致502错误.

最佳答案
你确定这个问题真的来自NGINX和websocket吗?

>首先,您可以尝试wcat作为websocket CLI,以确保websockets是否正常工作
>您还可以尝试在控制台中运行应用程序或查看日志(最高级别的debug / verbose)以查看是否存在基础错误

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读