Detecting the correct Nginx virtual host

Detecting the correct Nginx virtual host

I recently installed Nginx onto an Ubuntu 10.04 machine to try to learn how to use it over Apache. I installed using aptitude. I correctly set up a virtual host under /etc/nginx/sites-available and created a symlink to /etc/nginx/sites-enabled and deleted the defaults there.

The site was working fine until I manually edited the aptitude sources file and performed an upgrade, now I'm noticing that the virtual hosts I assigned are being overwritten by a new configuration file in /etc/nginx/conf.d. How can I revert to detecting the virtual hosts from the /sites-enabled directory? Why did the update change where nginx detects virtual hosts?

答え1

The main nginx config file is /etc/nginx/nginx.conf. There is a line at the bottom that reads:

include /etc/nginx/conf.d/*.conf;

While this is part of the default config (and has been for some versions), the more recent versions move the default server from this main config file to /etc/nginx/conf.d/default.conf.

The most likely scenario is that a new file (default.conf) was added to your conf.d directory, and automatically included in your configuration. (Usually, updates will not overwrite existing config files, but they will add any new config files - which your existing config just may be set to include).

Check the main nginx.conf file to confirm, and rename (or delete) the new file in /etc/nginx/conf.d/ (possibly default.conf) to disable it.

関連情報