30 articles
Knowledge Base
Nginx
30 articles in the Nginx category · page 1 of 2.
- nginx 504 Gateway Time-out: find and tune the right timeout Fix an nginx 504 Gateway Time-out by reading the error log to see which timeout fired, then raising it only for the slow URL. You will also line up the timeouts of your CDN, load balancer and app so the right layer gives up first.
- Install CrowdSec on Nginx and enforce bans with a bouncer Learn how to install CrowdSec on an Nginx server and connect the nginx bouncer so detected attacks are actually blocked. You will also allowlist your own addresses and log the real visitor IP when a CDN sits in front.
- Proxy WebSocket connections through Nginx Configure Nginx as a WebSocket reverse proxy so a browser connecting over wss:// reaches your backend and the connection stays open. You will forward the upgrade headers, switch the upstream to HTTP/1.1, raise the idle timeout, and confirm the handshake returns 101 Switching Protocols.
- Scripting nginx with njs: js_import, js_set, and js_content for request-time logic Install the nginx njs JavaScript module, then use js_import, js_set, and js_content to validate a signed token, compute a cache key, and pick an upstream at the edge — plus the limits njs will not cross.
- Enable HTTP/3 (QUIC) on nginx: build check, listen directives, Alt-Svc, and verification A working nginx HTTP/3 setup: confirm your build has the v3 module, pair listen 443 quic reuseport with listen 443 ssl, send the Alt-Svc header browsers need, open UDP 443, and verify a real QUIC connection with curl.
- Cache upstream responses in Nginx with proxy_cache A practitioner guide to Nginx proxy_cache: define the cache zone, turn it on for a proxy_pass location, read X-Cache-Status, override upstream cache headers, serve stale on backend errors, and purge without Nginx Plus.
- How Nginx location and try_files Routing Works How nginx picks the winning location block and how nginx try_files resolves a request to a file, a directory, or a fallback — the model behind most nginx 404 confusion.
- Fix nginx 502 Bad Gateway: diagnosing the upstream A troubleshooting guide for the nginx 502 bad gateway error from a proxied upstream — read the error log, confirm the backend is listening, and fix connect failures, timeouts, buffers, and SELinux.
- Nginx HTTP load balancing — upstream blocks, methods, and what to watch How to spread HTTP traffic across multiple backends with Nginx upstream blocks — round_robin, least_conn, IP hash, and the keepalive setting most configs forget.
- Nginx stream module — proxying TCP and UDP for databases, mail and more How to use the Nginx stream module to load-balance plain TCP (PostgreSQL, Redis, SMTP) or UDP (DNS, syslog) traffic — the configuration is different from http but the patterns rhyme.
- Nginx upstream keepalive — tuning the connection pool between proxy and backend Most Nginx reverse proxies leave the upstream keepalive pool at zero by default. A short run-through of what to set, why, and how the math actually works.
- Redirecting HTTP to HTTPS in Nginx — the right way and the wrong way How to do the 80→443 redirect in Nginx without leaking redirect loops, HSTS surprises, or ACME validation failures. The minimal block, plus what to add for HSTS preload.
- Setting up Nginx as a reverse proxy in front of an application server How to put Nginx in front of Node, Python, PHP-FPM, or any HTTP upstream — proxy_pass, the headers that matter, buffering trade-offs, and the timeouts that prevent silent 504s.
- Nginx SSL session cache and tickets — TLS resume on busy frontends A walkthrough of ssl_session_cache, ssl_session_tickets, and ssl_session_timeout — what TLS resume saves, and the multi-worker pitfalls.
- Proxying WebSockets through Nginx — the Upgrade dance and the timeouts that matter How to configure Nginx to proxy WebSocket connections, the HTTP/1.1 Upgrade headers, and the read/send timeouts that turn 60-second drops into long-lived sessions.
- Static asset caching in Nginx — Cache-Control, ETag, and immutable fingerprinted files How to set Cache-Control on static files in Nginx for long-life caching of fingerprinted assets, ETag versus Last-Modified trade-offs, and the open_file_cache that pays off at scale.
- Nginx logs — access format, error levels, and logrotate that does not lose lines How to define an access log format Nginx can emit (including JSON), tune error_log levels, and configure logrotate so reload during rotation does not lose log lines.
- Enabling HTTP/2 on Nginx — the one-line change and what it actually does How to enable HTTP/2 (and HTTP/3 with QUIC) on Nginx, what changes in the wire protocol, and the practical performance behaviour to expect on a real-world site.
- Installing Nginx on Ubuntu — packages, firewall, and the first sanity check A clean install of Nginx on Ubuntu LTS — apt package vs upstream repo, UFW rules, default site layout, and the smoke tests that catch a broken install before it ships.
- Nginx server blocks — virtual hosts the way Debian organises them How to lay out multiple Nginx sites with sites-available and sites-enabled, scope server_name correctly, and keep the default_server trap from biting the next operator.
- The Nginx map module — clean redirects, decision tables, and why if is the wrong tool How the map directive replaces brittle if chains in Nginx, builds compact redirect tables from a file, and acts as the foundation for header-based decisions.
- Nginx hardening checklist — the production posture we apply on every host The Nginx hardening items we go through on every server — version hiding, TLS posture, body limits, timeouts, default-server, and the rest of the items that make a baseline.
- TLS on Nginx with Let's Encrypt — certbot setup and renewal How to issue and auto-renew Let's Encrypt certificates for Nginx with certbot, plus the HSTS, OCSP stapling, and renewal-monitoring details that keep TLS healthy.
- Rate limiting in Nginx with limit_req — what burst really means How to use limit_req_zone and limit_req in Nginx to throttle abusive clients, the leaky-bucket model, and the difference between nodelay and delay that catches most operators.