Copy · paste · nginx -t · reload

Nginx config you can actually paste.

Complete server and location blocks — reverse-proxy to an app, proxy WebSockets, redirect HTTP→HTTPS and www→apex, SPA try_files, gzip/brotli, cache, rate-limit, Basic Auth, raise the upload size, and modern TLS — each with the test and reload commands.

19 snippets

You know Nginx can do it. You don't remember the exact directive.

Each snippet is a focused, copy-paste config block for a real task, with a one-line explanation, where it belongs, the nginx -t / reload commands, and the gotchas.

FAQ

Are these Nginx snippets free?

Yes. Every snippet is free to read and copy, with no account or paywall.

Where do I put them?

A location block goes inside a server { } block (sites-available/ on Debian/Ubuntu, conf.d/ on RHEL). http-level directives like limit_req_zone, map and proxy_cache_path go in nginx.conf.

How do I apply a change safely?

Run "sudo nginx -t" to test, then "sudo nginx -s reload" (or systemctl reload nginx) for zero-downtime apply.

Reverse proxy or static?

Proxy to your app if it listens on a port; serve files statically if you only have built HTML/CSS/JS. SPAs do both via try_files.

Open the full interactive site ↗