What Is NGINX? Web Server, Reverse Proxy and Load Balancer Explained

NGINX explained for beginners: what it does as a web server, reverse proxy, load balancer and cache, why it is so fast, and how a request flows through it.

Published November 27, 2026

NGINX (pronounced "engine-x") is one of the most widely used web servers in the world. It serves static files, sits in front of application servers as a reverse proxy, spreads traffic across backends, terminates HTTPS, and caches responses. If you deploy anything to a Linux server, you will meet NGINX sooner or later.

The concept

NGINX was created in the early 2000s to solve the C10K problem: handling ten thousand simultaneous connections on one machine. Traditional servers of the time often used one process or thread per connection, which consumed memory and CPU on context switches as connections grew. NGINX instead uses a small number of worker processes, each running an event loop that handles thousands of connections without blocking.

That design makes NGINX excellent at the jobs that involve lots of connections but little computation per connection: serving files from disk, shuffling bytes between clients and backends, terminating TLS, and holding slow client connections so that application servers are not tied up by them.

NGINX usually does not run your application code. Your PHP, Python, Node.js or Java app runs in its own server (PHP-FPM, Gunicorn, Node, Tomcat). NGINX receives the request first, serves what it can directly (images, CSS, JavaScript), and forwards the rest to the application.

Where NGINX sits

requestproxy_passqueryBrowserHTTPSNGINXTLS, static, cacheApp serverNode / PHP-FPMDatabaseMySQL / Postgres
NGINX sits at the edge: clients talk to NGINX, NGINX talks to your app.

The jobs NGINX does

RoleWhat NGINX doesKey directives
Web serverServes files from disk with sendfile and caching headersroot, index, try_files
Reverse proxyForwards requests to app servers and returns responsesproxy_pass, fastcgi_pass
Load balancerSpreads requests over several backendsupstream, least_conn
TLS terminatorHandles HTTPS so apps speak plain HTTP internallylisten 443 ssl, ssl_certificate
CacheStores backend responses and serves them directlyproxy_cache, proxy_cache_path
Virtual hostingHosts many sites on one IPserver_name

Why the event model matters

Thread per connection10k conns ≈ 10k threadsNGINX event loop10k conns ≈ 4 workers
Conceptual comparison of concurrency models for idle keep-alive connections.

Installing and checking NGINX

sudo apt install nginx
systemctl status nginx --no-pager | head -3
● nginx.service - A high performance web server and a reverse proxy server
Active: active (running) since Thu 2026-11-27 09:30:12 UTC
curl -I http://localhost
HTTP/1.1 200 OK
Server: nginx/1.24.0 (Ubuntu)
ps -o pid,user,cmd -C nginx
PID USER CMD
1201 root nginx: master process /usr/sbin/nginx
1202 www-data nginx: worker process
Installed, running, and serving the default page with one master and its workers.

Practical examples

Serve a static site

The smallest useful configuration.

server {
    listen 80;
    server_name example.com;
    root /var/www/example;
    index index.html;
}

Reverse proxy to a Node.js app

NGINX handles the public port; the app listens only on localhost.

server {
    listen 80;
    server_name api.example.com;
    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Test and reload safely

Always test before reloading; reload keeps existing connections alive.

sudo nginx -t && sudo systemctl reload nginx

Common mistakes

  • Running application code inside NGINX expectations: NGINX does not execute PHP or Python itself; it passes requests to PHP-FPM or an app server.
  • Restarting instead of reloading, which drops active connections.
  • Exposing the app server port publicly as well as through NGINX.
  • Editing the default site and forgetting it still catches requests for unknown hostnames.

Key takeaways

  • NGINX is an event-driven web server, reverse proxy, load balancer and cache.
  • A few worker processes handle thousands of connections each.
  • It serves static content directly and forwards dynamic requests to app servers.
  • Use nginx -t before every reload.

FAQ

NGINX or Apache?

Both are mature. NGINX is typically chosen for reverse proxying and high concurrency; Apache offers .htaccess per-directory configuration and in-process modules like mod_php. Many stacks put NGINX in front of Apache or PHP-FPM.

Is NGINX free?

Yes. NGINX open source is free under a BSD-style license. NGINX Plus is a commercial edition with extra features such as active health checks and a live dashboard.

What is OpenResty?

A distribution of NGINX bundled with LuaJIT and modules, letting you script request handling in Lua.

More Nginx articles