What Is Nginx?

Category: Web Servers ยท Updated 2026-11-02

Nginx (pronounced "engine-x") is free, open-source web server software that also works as a reverse proxy, load balancer and cache. It uses an event-driven design that lets a small number of worker processes handle many simultaneous connections efficiently, which is why it is a common choice for serving static files and sitting in front of other applications.

What Nginx does

  • Web server: serves static files such as HTML, CSS, JavaScript and images directly and very efficiently.
  • Reverse proxy: receives requests from the internet and forwards them to backend applications, such as PHP-FPM, Node.js or another server.
  • Load balancer: spreads incoming requests across several backend servers.
  • Cache and TLS termination: can cache responses and handle HTTPS encryption before passing plain requests to a backend.

How Nginx handles connections

Instead of starting a new process or thread for every connection, Nginx uses a small, fixed number of worker processes, each able to manage thousands of connections at once through an asynchronous, event-driven loop. This keeps memory use low even under heavy concurrent traffic, which is one reason Nginx is popular for high-traffic sites and as the public-facing layer in front of other software.

Basic Nginx configuration

Nginx configuration is organized into server blocks, each handling one domain or site, and location blocks inside them that define how specific URL paths are handled. A minimal server block that serves static files looks like this:

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

    location / {
        try_files $uri $uri/ =404;
    }
}

Config files commonly live under /etc/nginx/, and site-specific files are often placed in sites-available and linked into sites-enabled on Debian-based systems.

Nginx vs. Apache, briefly

Apache reads per-folder .htaccess files, which Nginx does not support; all Nginx rules live in its central configuration and require a reload to apply. Many setups run both together, with Nginx in front handling static files, HTTPS and caching, and Apache or PHP-FPM behind it running the application.

Common uses in hosting

  • Serving a static site or single-page application directly.
  • Fronting a PHP application by passing requests to PHP-FPM.
  • Reverse-proxying a Node.js, Python or Java application running on a local port.
  • Terminating HTTPS and forwarding plain HTTP to internal services.
  • Balancing traffic across multiple backend servers or containers.

Frequently asked questions

What is Nginx used for?

Nginx is used as a web server for static files, as a reverse proxy that forwards requests to applications, as a load balancer across multiple servers, and to handle HTTPS encryption and caching in front of other software.

Is Nginx a database or a web server?

Nginx is a web server and reverse proxy, not a database. It serves files and routes requests, while a separate system such as MySQL or PostgreSQL stores and queries data.

Does Nginx support .htaccess files?

No. Nginx ignores .htaccess files entirely. Rewrite rules and access controls must be written directly into the Nginx configuration files and applied with a reload.

What port does Nginx listen on by default?

A freshly installed Nginx server typically listens on port 80 for HTTP, and a separate server block using port 443 is added for HTTPS once a TLS certificate is configured.

How do I restart Nginx on Linux?

On most Linux distributions, run "sudo systemctl restart nginx" to restart it, or "sudo nginx -t" first to test the configuration for syntax errors before reloading with "sudo systemctl reload nginx".

Is Nginx free to use?

Yes. The open-source Nginx web server is free to download, install and use. A separate commercial product, Nginx Plus, adds paid support and extra features on top of the free core.

Related topics