Answer the question
In order to leave comments, you need to log in
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;
}
}
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question