Score:0

Why some nginx configs are missing the http block?

sb flag

According to the nginx beginner's guide:

Serving Static Content

An important web server task is serving out files (such as images or static HTML pages). You will implement an example where, depending on the request, files will be served from different local directories: /data/www (which may contain HTML files) and /data/images (containing images). This will require editing of the configuration file and setting up of a server block inside the http block with two location blocks.

But most of the nginx conf files are missing this http { ... } part.

I can't find anything on the document describing about it.

Is this http { ... } block just optional? When should I use/omit it?

Score:2
za flag

http {} block is essential for serving HTTP and is mandatory for it. The thing is, it's defined in the main nginx.conf configuration file, not in the includes. So includes only define a server {} block, at least one for each vhost, and they are actually included inside the http {} block in the main config file.

AGamePlayer avatar
sb flag
Thanks, it's my fault to ignore the parent conf file.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.