# Nginx

> Nginx is an open‑source web server that can serve static files, forward requests to upstream servers, and balance traffic across multiple back‑ends.

Search engine optimisation · Updated 2026-08-29 · [Marketing glossary](https://www.getlooploop.com/glossary)

**In short** Nginx is a program that receives web requests and sends back responses, often used to host websites or to forward requests to other servers.

## What it is and how it works

Nginx uses an event‑driven, non‑blocking I/O model. A master process reads the configuration file and spawns one or more worker processes. Each worker can manage thousands of simultaneous connections using a small set of file descriptors. When an HTTP request arrives, Nginx parses the request line, matches the URI against the defined location blocks, and either serves a static file from the disk or forwards the request to an upstream server with the `proxy_pass` directive. The response is then returned to the client. This design allows Nginx to achieve high throughput and low latency while consuming relatively little memory.

## What to do about it

Install Nginx from your operating system's package manager or compile it from source. After installation, create a server block in `/etc/nginx/sites‑available/` that specifies the domain name, root directory, and any proxy or rewrite rules. Enable the site by creating a symbolic link to `/etc/nginx/sites‑enabled/`, then test the configuration with `nginx -t`. If the test passes, reload Nginx using `systemctl reload nginx` or send a HUP signal to the master process. To improve performance, set `worker_processes` to the number of CPU cores, enable `keepalive` connections, and consider adding `proxy_cache` for repeated requests.

## How it is measured or noticed

Nginx writes each request to the access log (`/var/log/nginx/access.log`), recording the client IP, request method, status code, and response size. Errors are logged to `/var/log/nginx/error.log`. You can use benchmarking tools such as `ab` (Apache Bench) or `wrk` to send concurrent requests and measure latency and throughput. The optional `nginx‑status` module provides a web page that displays active connections, total requests, and the current read/write state, which is useful for real‑time monitoring.

## Common mistakes

- Skipping `nginx -t` before reloading, which can cause a broken configuration.
- Using the default `root` directive without an `index` file, leading to directory listing.
- Exposing the backend application port directly to the internet instead of routing through Nginx.
- Neglecting to set `client_max_body_size` for file uploads, resulting in 413 errors.
- Misconfiguring `proxy_pass` with a trailing slash, which changes the URI passed to the upstream server.

## Limits

Nginx is optimized for static file serving and reverse proxying, but it is not a general‑purpose application server. It cannot execute Python, Ruby, or PHP code directly; those languages require a separate process such as uWSGI, Gunicorn, or PHP‑FPM. The built‑in load balancing algorithms are limited to round‑robin, least connections, and IP hash; more advanced routing may need external tools. Additionally, each worker process can handle a finite number of connections defined by `worker_connections`, so very high concurrency may require tuning or additional workers.

## Worked example

> server { listen 80; server_name example.com; location / { proxy_pass http://backend:8080; } }

## Quick check

Run `systemctl status nginx` to confirm the service is active and not reporting errors.

## Frequently asked questions

### How does Nginx differ from Apache?

Nginx uses an event-driven architecture to handle many concurrent connections with low memory, whereas Apache typically uses a process-based approach. This makes Nginx generally faster for serving static content and acting as a reverse proxy.

### Should I use Nginx as a load balancer or a web server?

It depends on your infrastructure needs, as it can perform both roles simultaneously. You can use it to serve your frontend files while distributing API requests to various backend servers.

### What happens if Nginx is misconfigured?

The server will likely fail to start or return `502 Bad Gateway` and `403 Forbidden` errors to users. You would notice this through failed health checks or by checking the error logs in `/var/log/nginx/error.log`.

## Asked out loud

The same term in the words somebody uses speaking to an assistant rather than typing into a box — written from the situation, which is why each one carries the situation it came from.

### I've got a massive spike in traffic and my app is crashing, what can I put in front of it to handle the load?

Nginx is the standard choice for this. It can act as a reverse proxy to buffer requests and balance traffic across multiple server instances to prevent crashes.

### My client's site is showing a white page with a server error, what software is usually managing the routing here?

It is very often Nginx. You should check if the service is running or if the configuration file has a syntax error causing the outage.

### I'm on my phone and need to know which open-source tool is best for serving static files quickly without eating all my RAM.

Nginx is the best fit for that requirement. Its non-blocking I/O model is specifically designed for high-performance static content delivery.

## Sources

- [Robots Exclusion Protocol (RFC 9309)](https://www.rfc-editor.org/rfc/rfc9309.html)

Source: GetLoopLoop Glossary — https://www.getlooploop.com/glossary/nginx. CC BY 4.0: https://creativecommons.org/licenses/by/4.0/

---

Canonical page: https://www.getlooploop.com/glossary/nginx
This is the Markdown copy of that page for AI agents, made from the same content.

Other languages: [uk](https://www.getlooploop.com/uk/glossary/nginx.md) · [es](https://www.getlooploop.com/es/glossary/nginx.md)
