nginxhttp-status-code-502

nginx: 502 bad gateway if /index.html is not in URL


i don't understand what i'm doing wrong so i hope somebody can help :)

When i access http://10.0.0.54/index.html i get the right page but if i try to access http://10.0.0.54 instead of showing the index file it redirects me to https://10.0.0.54 showing error 502 bad gateway.

This is the configuration /etc/nginx/sites-available/default

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html/salvaderi;

        index index.html;

        server_name _;

        location ~ /.well-known/acme-challenge {
                allow all;
                root /var/www/html/salvaderi;
        }

        location / {
                root /var/www/html/salvaderi;
                index index.html;
        }
}

I am running nginx 1.18.0 on ubuntu 22.04

i tried changing parameters inside location /{} but i always get the same result. I also changed the root directory and made sure permission where set right. Searching on for the solution i saw other people having problems about PHP and FastCGI but i am not using it.


Solution

  • Your configuration about to be right.

    Possible there is some kind of proxy or load-balancer is placed between you and nginx you configuring since you got redirect to HTTPS whether there is no any redirection instructions in your config and, in the same time, there is no listen 443 ssl in config, but you still got response on HTTPS request.

    I'd check next: