A
A
Andrey2017-06-08 23:00:55
Nginx
Andrey, 2017-06-08 23:00:55

Where to place configs for virtual hosts in nginx?

I often see /etc/nginx/sites-available/ it in various nginx tutorials, but I haven’t seen anything like it myself. As I understand it, this was an old configuration in which files from /etc/nginx/sites-available/were included in nginx.conf.
At the moment I have two hosts and both configurations are registered in nginx.conf.
I wanted to learn about best practice, where is it better to place configurations for hosts? how is it done by you?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Burov, 2017-06-08
@andreychumak

On the subject: https://habrahabr.ru/company/oleg-bunin/blog/313666/
I have made the /etc/nginx/sites/ directory
and in nginx.comf sites-available, sites-enabled is made in Debian-based distributions include sites/*.conf;

E
Eugene Wolf, 2017-06-08
@Wolfnsex

as I understood it was an old configuration in which files from /etc/nginx/sites-available/ were included in nginx.conf
This is not an "old configuration", but (as already mentioned by the speaker above) - default settings for distributions derived from Debian (including Ubuntu and many others). The configuration is focused on hosting providers, so that it would be possible to conveniently "disable" the site, and not "completely delete" it (or its config).
Where to store the configs - where it is convenient for you, this has no practical significance, but historically / traditionally the configs are located in / etc, and the configs of a separate application in / etc / application_name, their further placement is a matter of taste / experience / common sense / personal preferences. Personally, I am completely satisfied with the config placement option (this is the option that you often see) adopted in Debian.
As for whether to include the config of each site in the main config - it’s absolutely a matter of taste, if you have 1.5 sites, then there’s no point in bothering too much and you can enter everything in the main config, if you have a dozen sites with different settings - I think it’s worth taking them out settings in separate files. And if you have a hundred sites, and some of them periodically need to be disabled (for non-payment, for example) - the debian configuration option (described earlier) looks quite attractive.

S
sim3x, 2017-06-09
@sim3x

For a long time, such configs migrated to a directory named /etc/nginx/conf.d/
You don’t need to store it anywhere
Store the config in sites-avaliable, and then sculpt the symlink to another directory - strange
Store it in nginx.conf if you are not afraid to lose configs sites when updating nginx

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question