We are trying to run a Meteor application on a Debian server behind Nginx. The application is running but GET requests at http://url/sockjs?info?cb=[random_string]
returns 502 Bad Gateway
.
The Nginx configuration is set up as thus:
# 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;
}
}
}
We have tried various configurations and could not figure out where the fault lies. Solution at Meteor WebSocket handshake error 400 with nginx didn't work either.
Edit: Tried following configuration found at recommended nginx configuration for meteor and it was still returning 502.
Edit: The application works fine when not obtaining images from Meteor CFS, which is used to store uploaded images via an admin dashboard. When loading images, a POST to domain/sockjs/img_location/cb/xhr_send causes a 502 error.
Are you sure the issue is really coming from NGINX and websocket?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With