📝 Tutorials

What is Nginx? A Simple Explanation for Developers


Nginx (pronounced “engine-x”) is a web server that does three things really well:

  1. Serves static files — HTML, CSS, JS, images. Faster than any application server.
  2. Reverse proxy — sits in front of your app and forwards requests to it.
  3. Load balancer — distributes traffic across multiple app instances.

Most production web apps use Nginx even if you don’t realize it. It’s the most popular web server in the world.

Why you need Nginx

Your Node.js/Python/Go app can serve HTTP directly. But it shouldn’t in production because:

  • Nginx serves static files 10-100x faster than your app
  • Nginx handles SSL/HTTPS termination
  • Nginx compresses responses (gzip/brotli)
  • Nginx handles thousands of concurrent connections efficiently
  • Nginx can rate-limit and block bad traffic
Internet → Nginx (port 80/443) → Your app (port 3000)

Nginx handles the boring stuff. Your app handles business logic.

Basic config

server {
    listen 80;
    server_name myapp.com;

    # Serve static files directly
    location /static/ {
        root /var/www;
    }

    # Proxy everything else to your app
    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

When you don’t need Nginx

If you deploy to Vercel, Netlify, Cloudflare Pages, or any PaaS — they handle all of this for you. Nginx is for when you manage your own server (VPS, EC2, bare metal).

For the full config reference, see the Nginx cheat sheet. See also: What is a Reverse Proxy? | What is HTTPS?