Which nginx-config file is enabled, /etc/nginx/conf.d/default.conf or /etc/nginx/nginx.conf?

There are two config files around, /etc/nginx/conf.d/default.conf and /etc/nginx/nginx.conf, but which one is enabled? I am running CentOS6.4 and nginx/1.0.15.


Technically, nginx.conf is all that matters, if you define every thing inside there it would still work, but to keep things organized, they use include, somewhere at the end of nginx.conf you'll see include /etc/nginx/conf.d/* and in some distros you'll also find include /etc/nginx/sites-enabled/* this is a convention to keep things organized, you create your server blocks in that conf.d or sites-enabled folder and it would be included here as if it's written in the nginx.conf file.

Of course you can add your own include lines there normally and create your own new conf folder that would be auto included.

TIP: These files are included in alphabetical order, you need to keep that in mind if you don't specify any server as default_server, because first one would be the default.


the general configuration of nginx is in /etc/nginx/nginx.conf. /etc/nginx/conf.d/default.conf is used to configure the default virtual host. For this you can also use sites-available and sites-enabled.

You can find more details at a blog entry from digital ocean How To Configure The Nginx Web Server On a Virtual Private Server


for save time.

  • if you just have 1 site to host, nginx.conf is ok. but,
  • if you have 2~n sites, for more clear config, you should use conf.d fold.

detail.