Skip to content
BENIBIX Learn

nginx.conf

Infrastructure🌍 Web Serving & NginxServer Configuration

Also known as Nginx Configuration File, Nginx Config File

The main settings file for Nginx. It holds short rules grouped in blocks.

Think of it like

It is like the rules on a kitchen wall. All the cooks follow them. Change one, and the whole kitchen changes.

Example

Emma raises the upload limit for her whole server. She adds one line to the http block, runs a test and reloads.

Why it matters

Every change to Nginx starts here. One missing semicolon and the server will not reload.

Definition

nginx.conf is the main settings file for Nginx. It is most often found at /etc/nginx/nginx.conf. It is made of rules called directives, and each one ends in a semicolon. Curly brackets group them into blocks. The http block holds web settings, and a server block inside it holds each site. On Ubuntu, it also pulls in one extra file for each site.

Example code

nginx
http {
    client_max_body_size 20m;
    include /etc/nginx/sites-enabled/*;
}
The http block holds settings for every site. The include line pulls in one file per site.
The big box is nginx.conf. The server blocks for each site sit inside it.

Common mistake

Forgetting the semicolon at the end of a line. Run nginx -t, and it names the line that broke.

Key takeaways

  1. 1
    Directives. Each one ends in a semicolon.
  2. 2
    Blocks. http holds server, server holds location.
  3. 3
    Test first. Run nginx -t before a reload.