1

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.

1 Answer 1

1

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:

  • Is 10.0.0.54 in fact IP of your server?
  • Is there any return 301, return 302 or rewrite instructions in your nginx config (the better way is to dump config with nginx -T command and look over).
  • Didn't you previously have configured some redirects that may have been cached by your web client previously? Try to send GET request with curl instead of web browser (if browser been used for tests).
Sign up to request clarification or add additional context in comments.

2 Comments

Didn't you previously have configured some redirects that may have been cached by your web client previously? it was this problem. Such a stupid thing to think now, i spent so much time on it... Thank you very much
I had location ~ ^/[A-Z]+[a-z0-9]*([A-Z]*[a-z]*)* { proxy_pass http://127.0.0.1:4321; } in my config from an old wiki, that was causing this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.