nginx Config Generator
Design and optimize production-ready Nginx server block configurations.
1. Server Info
2. Application Settings
3. SSL Configuration
4. Security & Optimization
Understanding your generated nginx Configuration
Save this configuration inside your Nginx config path, normally at /etc/nginx/sites-available/example.com. Then create a symbolic link to activate it:
ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
Always test your configurations using nginx -t prior to restarting or reloading Nginx to avoid server downtime. Apply changes safely via:
systemctl reload nginx
This configurator follows best practices, specifying modern SSL suites, HSTS protections, proxy caching, standard websocket upgrade parameters, and essential security headers like X-Frame-Options to lock down your deployments from common vulnerabilities.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Producing a server block for a static site or a reverse proxy.
- Getting the proxy header set right for an upstream application.
- Producing an HTTP-to-HTTPS redirect block.
- Getting a single-page-app fallback right, which is where most hand-written blocks go wrong.
- Producing a reverse-proxy block for a Node or PHP upstream.
Frequently Asked Questions
- What kinds of site can it configure?
- A static root, a reverse proxy to an application port, PHP through FPM, and a pure redirect to another domain. Each produces the matching `location` blocks rather than a generic template you then have to edit.
- What is the difference between the modern and intermediate TLS profiles?
- Modern is TLS 1.3 only — the strongest, and it locks out older clients. Intermediate keeps TLS 1.2 with a safe cipher list and is the right default for a public site. They follow Mozilla's published configurations.
- Do I need the websocket option for a proxy?
- Only if the application uses them, but it costs nothing to include: it sets `Upgrade` and `Connection` headers on the proxied request. Without them the handshake fails and the connection falls back or drops, which is a confusing symptom to debug.
- What does the real-IP option do?
- Forwards the client address with `X-Real-IP` and `X-Forwarded-For`, so the application logs the visitor rather than the proxy. Behind a CDN you also need `set_real_ip_from` for its ranges, or you will trust a header anyone can send.
- Should I enable HSTS preload straight away?
- No. Preload is effectively irreversible — removal takes months to reach users — and it applies to every subdomain. Run with a short `max-age` first, confirm nothing on any subdomain needs plain HTTP, then extend and consider preloading.
- How do I apply the generated file?
- Save it under `sites-available`, symlink it into `sites-enabled`, then run `nginx -t` and reload. Always test before reloading — an invalid file makes nginx refuse to start, and the reload is where you find out.
Common errors and gotchas
- Omitting the forwarded headers on a proxy, so the application sees the proxy's address as the client's.
- Getting `try_files` wrong for a single-page app, which then 404s on a deep link.
- Creating a redirect loop between the HTTP and HTTPS blocks.
- Setting a very long cache time on files with no hash in their names.
- Deploying without running the server's own config test, which catches most of this in a second.
Related Developer Utilities tools
RegExp Tester
Test regular expressions and inspect matches locally.
Regex Visualizer
Visual regex pattern diagram with live match highlighting and capture group annotations.
Subnet Calculator
Compute CIDR subnets, usable hosts, and network ranges.
Cron Parser
Translate cron syntax into plain English.
URL Parser
Break a URL into protocol, host, path, and query parts.
HTML Previewer
Paste HTML and see it rendered live in a safe, sandboxed preview.
HTTP Status Code Reference
Search and look up every HTTP status code and its meaning.
MIME Type Lookup
Find the MIME type for a file extension, or the extensions for a MIME type.