Adding New Server Block NGINX

October 20, 2017 4k views
Nginx Ubuntu 16.04

Hello All!

I am trying to parse this tutorial here, but my server configuration is already a little different, so I’m not working from scratch and need some help to make sure I don’t blow anything up.

Right now, most of my files are in /var/www/html – this includes files for three domains. My current server blocks are located not in the sites-available, but in the nginx.conf file. And, they use SSL from LetsEncrypt.

My goal is to add a new domain that’s root is /var/www/ and has a separate LetsEncrypt cert. If it’s okay adding the new server block as a separate file in sites-available, I’d prefer to do that. However, if I need to put it in the nginx.conf with the others, that’s fine too.

I’m just a little unsure how to put it all together.

Any help would be immensely appreciated.



1 Answer
emils October 20, 2017
Accepted Answer

Does your nginx.conf containes these lines in the bottom of HTTP block ?

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

? If yes. Then just add new config under sites-enabled folder and you’re ready to roll

  • Yes, those lines are in the file.

    Should I also put the new server block in /etc/nginx/sites-available/?

    • Actually, you can create it @ sites-available folder and then create symbolic link to sites-enabled folder

      sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

      Like in that line, just replace with your domain

Have another answer? Share your knowledge.