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?
http {}
block is essential for serving HTTP and is mandatory for it. The thing is, it's defined in the mainnginx.conf
configuration file, not in the includes. So includes only define aserver {}
block, at least one for each vhost, and they are actually included inside thehttp {}
block in the main config file.