Nginx Config Generator

Fill in a server name, root or upstream and a few options to get an Nginx server block for a static site, reverse proxy, SPA or plain HTTPS redirect.

Use the tool

Why this tool exists

Nginx configuration is short but unforgiving. A missing semicolon, a try_files line that sends every URL to 404, or a proxy block without the forwarded headers can take a site down or break logins behind a proxy. Most setups repeat the same few patterns, so they are easy to get from a template.

This generator covers four: a static site with long-lived caching for assets, a single-page app that falls back to index.html, a reverse proxy to an upstream with the headers apps usually need, and a lone redirect from HTTP to HTTPS. You can add gzip settings and a certificate block that points at Let's Encrypt paths. Always run nginx -t before reloading. The text is generated in your browser.

How to use it

  1. Choose the type: static, reverse proxy, SPA or https redirect only.
  2. Enter the server_name and, depending on the type, the root folder or the upstream address.
  3. Tick HTTPS and gzip as needed.
  4. Copy the config, test it with nginx -t and reload Nginx.

Frequently asked questions

Where do the certificate paths come from?

With HTTPS ticked, the block points at /etc/letsencrypt/live/ followed by your server name for fullchain.pem and privkey.pem, the usual Certbot location. Change the paths if your certificates live elsewhere.

What does the SPA option do differently?

It sends any URL that is not a real file to /index.html, so client-side routes such as /dashboard load the app instead of returning 404. The static option returns 404 for missing files.

Which headers does the reverse proxy add?

Host, X-Real-IP, X-Forwarded-For and X-Forwarded-Proto, plus Upgrade and Connection settings so WebSocket connections can pass through. Adjust timeouts and buffering for heavy workloads.

Is the output complete for production?

It is a solid base but omits security headers, rate limits, TLS tuning and logging choices. Review those for your environment, and test the file before reloading.