About

About

Copy-paste Nginx config — by someone who got tired of re-reading the docs and pasting half-right blocks from forum answers.

Nginx is the web server and reverse proxy in front of a huge share of the internet, and it does far more than serve files: it proxies apps, terminates TLS, redirects and rewrites URLs, compresses and caches responses, load-balances, and rate-limits. But the exact block — the WebSocket Upgrade headers, the try_files fallback for a single-page app, the trailing-slash rule on proxy_pass, where limit_req_zone has to live — is easy to forget between uses. This site collects the config that actually comes up into one library.

Each snippet is a complete, working server or location block with a short explanation of the important lines, where in the config it belongs, the nginx -t test and reload commands, and the common gotchas. The directives target modern Nginx (1.18+); where something is version-sensitive (http2 on;, brotli) the snippet says so.

Topics: reverse proxy (apps, WebSockets, load balancing, subpaths), redirects & rewrites (HTTP→HTTPS, www→apex, path changes), static files & SPAs, caching & compression (gzip/brotli, asset cache, proxy cache), HTTPS/TLS (modern config, Let's Encrypt), access & rate limiting (rate limits, Basic Auth, upload size), and how to test and reload safely. This is about routing, proxying and caching — for HTTP security headers (CSP, HSTS) see our sister site headerforge.