2

I have nginx.conf file which has several blocks of server, each for a subdomain.

I am reading the concept of sites available and enabled. And that the available folder can contain multiple files, and using a command a site can be enabled which copies the file into the enabled directory.

What I want to as is - how does nginx config read the files in site enabled directory? In the nginx.conf I cannot see any reference to this path so how does the nginx link to the sites enabled directory?

1 Answer 1

2

If your distribution uses the "sites-enabled" system, your nginx.conf will simply have an include for everything in that directory (example taken from Debian 11):

http {
    [...]

    # Virtual Host Configs

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

However, not all distributions use this system. Some only provide a basic nginx.conf that doesn't try to include any additional config files at all.

3
  • Ok so without the include in nginx.conf, the contents in the sites enabled directory is of no use?
    – variable
    May 20, 2022 at 9:19
  • Yes, it'll just be ignored. May 20, 2022 at 9:20
  • For me this worked. Thank you!
    – Stephan K.
    Jun 5, 2023 at 20:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .