Where do I put specific domain configuration files on an nginx server? I've seen a lot of conflicting information. Does it belong in the sites-enabled folder? If so, do I put it in the already created (via symlink) www.mysite.com file? Or do I create a www.mysite.com.conf file? Or do I put the www.mysite.com.conf in the conf.d directory? I'm just trying to add some media specific caching rules particular to one website hosted on my nginx server (so not in the nginx.conf file). I just want to make this config file particular to a website. I'm unsure of where to place the config file and placing it conf.d under www.mywebsite.com.conf or in the sites-enabled under the same name has not worked. Thanks.
Asked
Active
Viewed 798 times
1
-
It really depends on what the main `nginx.conf` file looks like, based on its `include` directives. I personally don't use any other files at all for my virtual hosts and define all of them in nginx.conf, removing the include directives. For only a few vhosts, that works really well and I suggest you do the same. – Mar 24 '15 at 14:04
2 Answers
2
Nginx packaging changed : the conf.d
folder was used in old packages, sites-enabled
/ sites-available
is used now with sites-available
directory containing actual vhosts configurations and sites-enabled
the symlinks to sites-available
vhosts you want to activate.
So a typical structure would now be :
nginx
├── nginx.conf
├── sites-available
│ ├── mysite1
│ └── mysite2
└── sites-enabled
└── mysite1 -> ../sites-available/mysite1
However, you have the liberty to do it whatever way you want, and even use none of these structures. Simply put the relevant include
directive(s) in your main configuration file.

Xavier Lucas
- 13,095
- 2
- 44
- 50
0
Just put the files here.
/etc/nginx/sites-available/site1/
And do soft link
ln -s /etc/nginx/sites-available/site1/ /etc/nginx/sites-enabled/site1/

Booth
- 488
- 2
- 4
- 11