Question

Weird problem - site works, except for the index page

Posted May 31, 2020 228 views
Nginx

I have an Nginx setup that serves a couple of websites for years and I ve never had any problems. Today I finally decided to try to add some certificates, with certbot and it didn’t go as planned - the site, fully static html - became inaccessible. I manually edited the server block file and removed all the lines added by the certbot, but to no luck. All the pages of the site now work EXCEPT for the index page.

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

    root /var/www/freethrow/html;
    index index.html index.htm index.nginx-debian.html;

    server_name freethrow.rs www.freethrow.rs;

    location / {
    try_files $uri $uri/ =404;
    }
}

Any help is more than welcome.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

Hello, @aleksendric

What you can do is to use the following line in the nginx.conf instead of the currently added one:

index.html index.htm index.nginx-debian.html;

You can also check the nginx config for syntax errors:

nginx -t

If the commands returns Syntax OK you’re good to go and you can restart Nginx and then re-test if everything is loading okay.

Let me know how it goes,
Alex

Yes, I tried but without the index part it doesn’t validate, it seems to be an Nginx directive…

Still no luck.

  • Hello, @aleksendric

    I will recommend you to examine the Nginx error log and see if there is any logged error as this will give you some additional information in order to troubleshoot the error.

    less /var/log/nginx/error.log
    

    You can also examine the log in real time using tail :

    tail -f /var/log/nginx/error.log
    

    Then all you need to do is to access the home page and see if there is a logged error in the log.

    Let me know how it goes.

    Regards,
    Alex

Submit an Answer