R
R
ravshan selimov2021-01-16 09:45:21
Nginx
ravshan selimov, 2021-01-16 09:45:21

How to solve 502 Bad Gateway nginx?

Hello.

Installed ghost cms according to documentation on VPS.
It started, there are no errors in the logs.

When accessing the domain, it gives 502.

2021/01/16 09:16:18 [error] 397571#397571: *545 connect() failed (111: Connection refused) while connecting to upstream, client: 185.163.27.157, server: children-planet.ru, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:2369/", host: "blog.children-planet.ru"
2021/01/16 09:16:18 [error] 397571#397571: *545 connect() failed (111: Connection refused) while connecting to upstream, client: 185.163.27.157, server: children-planet.ru, request: "GET /favicon.ico HTTP/2.0", upstream: "http://127.0.0.1:2369/favicon.ico", host: "blog.children-planet.ru", referrer: "https://blog.children-planet.ru/"


The call is made to a subdomain, can this be a problem.
When it was tied to a domain, not a subdomain, everything worked.
DNS records are correctly configured.
I did not touch the nginx configuration, when installing ghost cms it seems to configure itself.

I also removed and reinstalled nginx, I think the problem may be in this

Settings in /etc/nginx/sites/available/blog.children-planet.ru.conf
server {
    listen 80;
    listen [::]:80;

    server_name blog.children-planet.ru;
    root /var/www/blog.children-planet.ru/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2368;
        
    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 50m;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
ravshan selimov, 2021-01-16
@ravshan01

As I thought, the problem was that I removed and reinstalled nginx.
Cleaned up all garbage and restarted nginx and ghost cms

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question