Why it matters
nginx is powerful and unforgiving: a missing try_files breaks a single-page app's routes, a proxy without the right headers loses the client's IP, and add_header inside a location silently drops the headers set above it.
This generator writes a complete, commented server block for the common setups and explains each choice, including the traps. Test it with nginx -t on your server before reloading.
How it works
- InputDomain, site type and options
- In your browserBuilt from hardened defaults
- OutputA server block and setup steps
Where it fits in a designer's workflow
- Plan
- Design
- Build
- Test
- Launch
By the numbers
Show the numbers as a table
| Site type | Lines |
|---|---|
| Static site | 78 |
| Single-page app | 81 |
| Reverse proxy | 80 |
| PHP-FPM | 86 |
How to use it
- Enter your domain and choose what the server does.
- Pick HTTPS, headers, compression and caching options.
- Read the notes about the choices.
- Download the config and test it with nginx -t.
FAQ
Where does the file go?
Usually /etc/nginx/sites-available/ with a link in sites-enabled, or /etc/nginx/conf.d/yourdomain.conf. Then run sudo nginx -t and sudo systemctl reload nginx.
Does it get the certificate?
No. The paths match Certbot's defaults; run certbot --nginx -d yourdomain first.
Why are headers repeated in some locations?
nginx only inherits add_header lines if a location sets none of its own, so any location with its own headers needs them all.
Is HSTS safe to turn on?
Once every subdomain works over HTTPS. Browsers will refuse plain HTTP for the max-age you set.