Debugging nginx server block configuration

Hello, I’m trying to set up a very basic configuration to put a static website online.

I have a domain registered and I configured the nameserver on the domain provider and added it to the droplet.

I followed this tutorial:

and created a virtual host configuration for the website exactly like in the tutorial. It doesn’t work, I just get an “Unable to connect” error. I also made sure to remove the “default” configuration from the sites-enabled directory, but still the same.

I decided to go back to the basics and started reading this guide:

I managed to make it working just with these lines inside nginx.conf:

server { server_name; location / { root /var/www/; } }

I want to be able to put the configuration in separate files inside sites-availabel, though, so I tried again copying just the above lines, but nothing. Also, when the page fails to load nothing gets logged. I checked the configuration with sudo nginx -t and it says it’s ok. Where and how can I start debugging it?

Thanks for your help


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

No problem, good you checked the nginx configuration again. I thought you followed the DO tutorial so didnt put any attention to that, good you solved it.

Yes thats how links are supposed to be created, your server needs to know the absolute path to create a link. Otherwise it could also “search and find” a same named directory somewhere else that you dont want to link. So now it was linking a sites-available/ in the root directory. I hope this explaines your questions, for any more questions I’ll be happy to help you.

I would be interested in knowing how did you do the diagnostics on my server. So to learn something useful for the future

Allright, I am working from my Ipad now so I am not very fast and I can’t check alot of things. But from my diagnotics something is wrong with your server/nginx service. I checked your DNS and nothing is wrong with that, also your vhost looks good but you can try to run nginx without the ipv6 option.

Anyway what doesnt look good is your webserver. Port 80 isnt open or isnt being used by nginx. Check your nginx configuration to be sure it is running on port 80. Also check your firewall if youre running one, to make sure port 80 is open.

“the index.html file is in /var/www/” If your index.html is in there, why do you have the vhost root at /var/www/

This comment has been deleted

Please post the vhost of one of your test websites here, and the directory where you got this first website index.html.

How do you connect to your website? With the domain name or IP? Please post your domainname and how you got this setup, the records where and how.