nginx Nginx Configurations Configuration File’s Structure


nginx consists of modules which are controlled by directives specified in the configuration file.

Simple Directives

A simple directive consists of the name and parameters separated by spaces and ends with a semicolon (;).

Block Directive

A block directive has the same structure as a simple directive, but instead of the semicolon it ends with a set of additional instructions surrounded by braces ({ and }).


If a block directive can have other directives inside braces, it is called a context (examples: events, http, server, and location).

Directives placed in the configuration file outside of any contexts are considered to be in the main context. The events and http directives reside in the main context, server in http, and location in server.


The rest of a line after the # sign is considered a comment.