Do I need Nginx? Is this error I got a problem?

Posted November 6, 2016 3.7k views
NginxNode.jsGetting StartedConfiguration ManagementDigitalOcean 1-Click Apps MarketplaceDeploymentUbuntu 16.04Quickstart

It sounds like I need nginx to make my server available to the public but im not sure. And is it supposed to be installed on the same droplet as everything else?

I am following this guide:

I got this error when doing the first step:

Then when I try to edit “default server block configuration file” it comes up blank, and when I try to save it, it says no such file or directory.

I do get “Welcome to nginx!” in my browser.

I do not see an nginx folder in /etc/ so I’m not sure it installed to the right place.

1 comment
  • I ended up running the first command again, and it seems to have installed correctly, and put the right files in the right places. I was able to edit the file as the guide suggested.

    But now I still see the “Welcome to nginx!” page in my browser rather than the node hello world file. Any ideas?

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
1 answer

Did you created a new server block file instead of default?
If yes, you should delete default from /etc/nginx/sites-enabled and symlink new one to it:

  • sudo ln -s /etc/nginx/sites-available/your-block /etc/nginx/sites-enabled/

You can test configuration so you see is it correct:

  • sudo nginx -t

Make sure you restart nginx after symlinking or doing any other change to block:

  • sudo systemctl restart nginx

I would clean up browser cache just to be sure.
E.g. On Chrome you can use Ctrl+Shift+R to Hard Reload, or fire up console with F12, right click on refresh button and select Empty Cache and Hard Reload.

  • I didn’t do that, just replaced the default. Is there a reason to do that over default?

    Once of the users in the comments of that article pasted a script that does all of this for you, I tried it and seems to work, I was able to get hello world in browser. Hope there aren’t any downsides…

    • Didn’t used this myself, but looks good. Only thing that I would pay attention is Let’s Encrypt cert renew enabled.
      As far as I see, it is commented in script.
      Open crontab with:

      • sudo crontab -e

      It should have this:

      • 30 2 * * 1 /usr/bin/letsencrypt renew >> /var/log/le-renew.log
      • 35 2 * * 1 /bin/systemctl reload nginx

      It can work without it, but you have to renew it manually and you must be careful that it doesn’t expire. If it expires you’ll see error in browser when trying to access site saying that it’s not secure to proceed.

      No, there is no reason to use it over default. It’s useful when you have multiple domain setup so you can name files by domain name and know what each is.

      Why does tutorial steps didn’t work for, I can’t say for sure without look at config file, but as you got it working, it’s not needed anymore. :D