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
The jobs NGINX does
| Role | What NGINX does | Key directives |
|---|---|---|
| Web server | Serves files from disk with sendfile and caching headers | root, index, try_files |
| Reverse proxy | Forwards requests to app servers and returns responses | proxy_pass, fastcgi_pass |
| Load balancer | Spreads requests over several backends | upstream, least_conn |
| TLS terminator | Handles HTTPS so apps speak plain HTTP internally | listen 443 ssl, ssl_certificate |
| Cache | Stores backend responses and serves them directly | proxy_cache, proxy_cache_path |
| Virtual hosting | Hosts many sites on one IP | server_name |
Why the event model matters
Installing and checking NGINX
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 nginxCommon 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.