A
A
account-42017-03-12 03:36:08
Nginx
account-4, 2017-03-12 03:36:08

So where do you configure it: nginx.conf, conf.d, sites-available or sites-enabled?

Can someone explain to me. Why is everyone doing it differently? Over the past 2 days, I have found and read about 10 different tutorials, where there was the same simple task - running the simplest node.js application with nginx.
And in these tutorials, everyone solves the same task in different ways - in fact, the same config is written in 3 different places: nginx.conf, sites-available or sites-enabled.
What is this madness? So how is it right?
Where is the right place to configure nginx? config type:

server {
    listen 80;

    server_name example.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

+ later there will be SSL.
upd. and also met conf.d, forgot. Those. 4 ways to do the same thing?
It seems to be clear. Sites-enabled creates symlinks from sites-available. They, in turn, are included in nginx.conf. Those. you can manually write everything there, but it’s more convenient, especially when there are a lot of virtual hosts. True question then conf.d remains open .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Nesmeyanov, 2017-03-12
@account-4

As Aleksey correctly explained above, they usually do this, I’ll add a little (I will expand his explanations):
1. nginx.conf - common configs for the entire server and all the sites under it, at the same time it connects everything that is in site-enabled
2. site-available - configs of individual applications, you can plug one for webdava, another for websockets, the third for the site, the fourth for another site, and the fifth in general for php-fpm, etc.
3. sites- enabled there are just enabled sites - symlinks from site-available are added here in order to quickly enable, switch or disable some config. Sort of like a hot swap.
In a good way, everything is done just like that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question