我们正在尝试在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获取图像时,该应用程序运行正常,该文件用于通过管理仪表板存储上载的图像。加载图像时,对domain/sockjs/img_location/cb/xhr_send的POST导致502错误。
最佳答案
您确定问题确实出在NGINX和websocket吗?
关于 meteor ,WebSocket,Nginx 502错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34180188/