Report this

What is the reason for this report?

Debugging nginx server block configuration

Posted on July 14, 2015

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: https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-14-04-lts

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: https://www.nginx.com/resources/admin-guide/nginx-web-server/

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

server { server_name example.com; location / { root /var/www/example.com; } }

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



This textbox defaults to using Markdown to format your 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/example.com 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

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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.