Question

Nginx new server block still going to default page

Posted December 24, 2020 682 views
NginxUbuntuDigitalOceanUbuntu 20.04

Hello, I am new to the Ubuntu world and have been following the article,
https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04
however I have run into a bit of a problem!
I have got to the end of step 5 and all I am getting is the default Nginx page, not what I have typed in the html block.
I have it it again on a fresh ubuntu install and got the same issue.
what have I done wrong!?

1 comment

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.

×
Submit an Answer
2 answers

Hi @patrickb,

Can you please post the Nginx configuration file for the domain you are using? Additionally please let us know the path to the file you are posting so that we know everything looks alright.

As soon as we have the Nginx configuration file for your domain, we should be able to take a look at the way you’ve configured it and see if everything is done properly or needs to be changed a bit.

Regards,
KFSys

  • sorry bit new to this…is this what you are after?

    /etc/nginx/sites-available/domain.com

    server {
            listen 80;
            listen [::]:80;
    
            root /var/www/domain.com/html;
            index index.html index.htm index.nginx-debian.html;
    
            server_name domain.com www.domain.com;
    
            location / {
                    try_files $uri $uri/ =404;
            }
    }
    
    • Hi @patrickb,

      Yes, that’s what I’m after, thank you!

      First, I want to ask is that you’ve changed manually your domain with domain.com, correct? If not, you’ll need to use your domain there.

      Next thing to check if you have a symlink to your conf file in /etc/nginx/sites-enabled as well.

      Lastly, I can see your Nginx configuration to be configured properly but can you try restarting the service

      service nginx restart
      
      • hello, yes correct, domain changed.

        I have done the symlink step, but how do i get a list of sites enabled?

        restarted but still the same.

        thanks.

        • @KFSys sorry don’t think it notifies without tagging.

          • Hi @patrickb,

            In order to see what site has been enabled, you can just list the directory /etc/nginx/sites-enabled.

            As for your issue, that’s very strange, everything seems alright, the configuration file looks spot on.

            Another question, you do have a default config, correct? What does it say inside?

Show answer This answer has been marked as resolved by patrickb.