Skip to content
IT glossary
DevOps and cloudUpdated December 3, 2026

Nginx

A web server that can answer requests itself, for example by serving an image, or pass them to an application and relay its response. It can also distribute requests across multiple application instances.

Where Nginx fits

When a browser opens a site, Nginx (pronounced “engine-x”) may be the first server it talks to. Nginx can serve a stylesheet straight from disk while sending a request for a user's order history to the application. In the second case Nginx is acting as a reverse proxy: the client talks to Nginx, and Nginx talks to the backend, also called the upstream. The application still handles tasks such as checking permissions and querying a database.

How it handles traffic

For HTTP requests, Nginx selects a server block based on the listening address and port and the requested hostname. Within that server it matches the request URI against location rules. These rules determine whether to serve a file, send a redirect, or forward the request, among other actions.

The master process reads configuration and manages worker processes. Each worker uses an event loop and nonblocking network I/O to handle many connections. A worker doesn't need to wait idly for one client to send more data; it can handle another connection in the meantime.

Example: one frontend, two backend instances

Place these blocks inside the http context. Requests under /api/ are sent to a group of two application instances:

upstream api_pool {
    server 127.0.0.1:3001;
    server 127.0.0.1:3002;
}

server {
    listen 8080;

    location /api/ {
        proxy_pass http://api_pool;
    }
}

With the default round-robin policy and equal weights, Nginx normally distributes requests across the two instances in turn. Because proxy_pass specifies no URI, /api/orders reaches the selected instance as /api/orders in this example. Adding a trailing / to http://api_pool would replace the matched /api/ prefix with /, so the application would receive /orders instead.

Common deployment mistakes

Nginx can terminate TLS, which means the client's encrypted connection ends at Nginx. The connection from Nginx to the application is separate and uses HTTP or HTTPS as configured. Likewise, proxying does not enable response caching on its own. And while two backend instances can remove a dependency on any one instance, a single Nginx node can still be a single point of failure.

What interviewers look for

A common scenario is an API that works directly but returns 502 Bad Gateway through Nginx. Walk through the request path: check Nginx's error log, then verify that it can reach the configured upstream address and port from its own environment. For a configuration change, explain how you'd run nginx -t before nginx -s reload. A successful reload starts workers with the new configuration while old workers finish serving existing clients.