# nginx.conf

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

**Field:** Infrastructure  
**Category:** Web Serving & Nginx  
**Also known as:** Nginx Configuration File, Nginx Config File

## 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.

## 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

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

## 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.

## Why it matters

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

## Common mistake

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

## Three principles

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

## Related terms

- [Nginx](https://learn.benibix.com/term/infrastructure/nginx)
- [Nginx Server Block](https://learn.benibix.com/term/infrastructure/nginx-server-block)
- [Virtual Host](https://learn.benibix.com/term/infrastructure/virtual-host)
- [Configuration File](https://learn.benibix.com/term/development/config-file)

![Two site names, example.com and shop.example, both point to one server with one IP address. Inside the server, nginx.conf holds two server blocks. Each block matches one name and points at its own folder of files.](https://learn.benibix.com/diagrams/inf2-virtual-hosts.svg)

---

Source: https://learn.benibix.com/term/infrastructure/nginx-configuration-file
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
