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

Derek picture Derek · Mar 3, 2014 · Viewed 45.6k times · Source

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.

Answer

Mohammad AbuShady picture Mohammad AbuShady · Mar 4, 2014

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.