Nginx (pronounced "engine x") is an open-source web server that is also widely used as a reverse proxy, load balancer and HTTP cache. It uses an event-driven, asynchronous design, so a small number of worker processes can handle many simultaneous connections.
Why it matters
Nginx often sits in front of application servers, serving static files directly, terminating TLS, compressing responses and passing dynamic requests to PHP-FPM, Node.js or other backends. Many 502 Bad Gateway and 504 Gateway Timeout errors come from the proxy being unable to reach, or wait long enough for, the upstream. Configuration is a set of declarative blocks, and changes take effect after a reload.
Example
server {
listen 443 ssl;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_read_timeout 60s;
}
}
Test before applying with nginx -t, then run nginx -s reload.
Common mistakes
- Reloading without testing the config and taking the site down with a syntax error.
- Leaving default proxy timeouts, so slow backends return 504.
- Forgetting
proxy_set_headerlines, so the app sees the wrong host or client IP. - Confusing
rootandaliasinside location blocks.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.