Question

randomly my nginx config went bad. Yesterday my site was on just fine and today I get the 502 bad gateway. My sites enabled file looks like this

upstream myapp {
    server 0.0.0.0:3000;
}

server {
    listen   80 default;

    access_log /webservices/crawler/log/access.log;
    error_log /webservices/crawler/error.log;

    root   /webservices/crawler/public/;
    index  index.html;

    client_max_body_size 500M;

    location / {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;

        if (-f $request_filename/index.html) {
            rewrite (.*) $1/index.html;
            break;
        }

        if (-f $request_filename.html) {
            rewrite (.*) $1.html;
            break;
        }

        if (!-f $request_filename) {
            proxy_pass http://myapp;
            break;
        }
    }
}

"/etc/nginx/sites-enabled/default" 38L, 825C                                                                                   1,1           All

does anyone see what I need to change? Maybe my sites IP changed last night? I just have no idea and thank you to anyone that takes a look.

Was it helpful?

Solution

"502 bad gateway" answer means that there is an issue with "upstream" web server (second line in your config). Check Nginx error log and you will find a cause. It can be connection error, empty reply, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top