I have been working with nginx for some time and a little confused by multiple location where the nginx.conf scan be saved. I know the nginx.conf can be saved to 2 locations:
- /etc/nginx/sites-available/default
- /opt/nginx/conf/nginx.conf
Which location is better saving nginx.conf? Any difference with different location?
By default, the configuration file is named nginx.conf and placed in the directory /usr/local/nginx/conf, /etc/nginx (default for ubuntu), or /usr/local/etc/nginx. But you need to keep in mind that nginx can be installed in any directory, for example in the case of assembly from source. In you case - /opt/nginx/conf.
nginx.conf - general config of all server(it is possible to call it an entry point), there as a rule includes everything that placed in site-enabled and conf.d
conf.d - settings of individual parts or nginx modules, grouped for greater convenience.
site-available - configs of individual applications, services, sites and e.t.c. (the fact that they are here - does not mean that they will be included)
sites-enabled - here only enabled sites/apps/services. Here symlinks from site-available are added, in order to quickly enable or disable some config.