Skip to main content

Nginx

Pronunciation
EN-jin-EKS
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/nginx

In short

Nginx is a fast, open-source web server that is also widely used as a reverse proxy, load balancer and HTTP cache in front of application servers.

What is Nginx?

Nginx, pronounced "engine x", was created by Igor Sysoev and released in 2004 to solve a specific problem: serving many thousands of simultaneous connections on one machine. Instead of starting a new thread or process for every visitor, it uses a small number of worker processes that handle connections with an event loop, which keeps memory use low and steady under heavy load.

As a web server, Nginx serves static files such as HTML, CSS, images and downloads very efficiently. As a reverse proxy, it receives requests from the internet and forwards them to application servers written in Node.js, Python, PHP or anything else, so the app doesn't have to face the internet directly. On the way, it can terminate HTTPS, compress responses, cache them and enforce rate limits.

It can also act as a load balancer, spreading requests across several copies of an app, and as a gateway that routes paths like /api and /static to different places. All of this is described in a plain-text configuration file, usually nginx.conf, made of blocks such as server and location.

A common misconception is that Nginx runs your application code. It mostly passes requests to other processes that do; for PHP it talks to PHP-FPM, for Node.js it proxies to the Node server. It is one of the most used web servers in the world, alongside Apache httpd, and is also the basis of popular Kubernetes ingress controllers.

Key takeaways

  • Nginx is an open-source web server, reverse proxy, load balancer and cache.
  • An event-driven design lets it handle many thousands of connections cheaply.
  • It serves static files and forwards dynamic requests to app servers.
  • It can terminate HTTPS, compress, cache and rate-limit on the way.
  • Its behavior is set in a plain-text config file, usually nginx.conf.

Example

Serving static files and proxying an app (nginx.conf)nginx
server {
    listen 80;
    server_name example.com;

    # Static files straight from disk
    location /static/ {
        root /var/www;
    }

    # Everything else goes to the app on port 3000
    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;
    }
}

Readers ask

How do you pronounce Nginx?

It is pronounced "engine x".

What is the difference between Nginx and Apache?

Both are popular open-source web servers. Nginx uses an event-driven design that handles many connections with little memory and is often used as a reverse proxy, while Apache httpd traditionally uses a process or thread per connection and supports per-directory .htaccess files.

Is Nginx a load balancer?

It can be. Besides serving files and proxying requests, Nginx can spread traffic across several upstream servers using methods such as round robin or least connections.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings