I have nginx version 1.19.3 installed on my CentOS 7 server. My rocketchat application working on port 3000, 3001 and 3002. But my nginx server is not able to route proxy to Rocketchat. It is giving me 502 Bad Gateway error.
Here is my default.conf
# Upstreams
upstream backend {
least_conn;
server [::1]:3000 max_fails=3 fail_timeout=30s;
server [::1]:3001 max_fails=3 fail_timeout=30s;
server [::1]:3002 max_fails=3 fail_timeout=30s;
}
# HTTPS Server
server {
listen 443 ssl http2;
server_name example.com;
error_log /var/log/nginx/rocketchat.access.log;
ssl_certificate /etc/nginx/certs/example.com.crt;
ssl_certificate_key /etc/nginx/certs/example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # don’t use SSLv3 ref: POODLE
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Nginx-Proxy true;
proxy_read_timeout 5m;
proxy_pass http://backend;
proxy_redirect off;
}
}
Here is the error which i got in /var/log/nginx/rocketchat.access.log
2020/10/21 16:08:23 [error] 12532#12532: *25 no live upstreams while connecting to upstream, client: local-ip-address, server: example.com, request: "GET /favicon.ico HTTP/2.0", upstream: "http://backend/favicon.ico", host: "example.com", referrer: "https://example.com/"
I have enabled 3000, 3001, 3002 and I am able to access RocketChat through local ip address.
I have tried every solution which I found over stackoverfollow but it doesn’t work. Do anybody what could be the issue?
2
Answers
By setting keepalive to 8 in upstream works for me.
Is your Rocketchat app is running/accessible on IPv6 localhost address ::1 or IPv4 127.0.0.1?