Nginx
Nginx (pronounced "engine-x") is an open-source web server that also serves as a reverse proxy, load balancer and cache for static content. It appeared in 2004 as an answer to the so-called C10k problem — handling ten thousand concurrent connections — and quickly became one of the most widely used servers on the internet, especially for high-traffic sites.
How Nginx works
At the core of Nginx is an event-driven, asynchronous architecture. Instead of spawning a separate process or thread for each connection — as classic Apache does in prefork mode — Nginx runs a small, fixed number of worker processes, each of which handles many connections at once in a non-blocking event loop. The result is very low and predictable memory usage even under thousands of simultaneous requests.
Nginx serves static files (images, CSS, JavaScript) directly and efficiently, while it passes dynamic requests to a backend. For PHP this means forwarding them over FastCGI to PHP-FPM. Its entire configuration is kept centrally in server files — Nginx has no equivalent of .htaccess, which simplifies operation at the cost of per-directory flexibility.
Practical application
The most common roles for Nginx are as a web server for high-traffic applications and as a reverse proxy in front of other services. As a proxy it terminates HTTPS connections, caches responses and distributes traffic across multiple application servers, acting as a load balancer. A popular layout has Nginx accept traffic and serve static assets while routing dynamic requests to Apache running behind it.
On VPS and dedicated servers, Nginx is the default choice for stacks built on PHP-FPM, Node.js or Python, as well as the entry gateway in microservice and container architectures. Its light footprint and performance make it a good fit for both small instances and large, horizontally scaled production environments.
Powiązane pojęcia
Najczęstsze pytania
How does Nginx differ from Apache?
Nginx uses an asynchronous, event-loop model, so it handles thousands of concurrent connections efficiently with low memory usage. Apache traditionally assigns a process or thread per connection and allows per-directory configuration via .htaccess files. In practice the two often run together — Nginx at the front, Apache behind it.
