Skip to main content
ToolsHub

Nginx Config Generator

Pick your site type and options to generate a clean, production-ready nginx server block with HTTPS, gzip and proxy headers — instantly in your browser.

Updated

Files never leave your browser

How to use Nginx Config Generator

The Nginx Config Generator builds a clean, production-ready server block from a few choices, instantly in your browser. Pick whether you are serving a static site, a single-page application or a reverse proxy, set your domain and web root, and toggle options like an HTTPS redirect, gzip compression and a www alias. The tool then writes the matching nginx directives — listen, server_name, root, try_files, ssl_certificate and proxy headers — so you can copy a working configuration instead of hand-assembling it from scattered documentation and Stack Overflow answers.

  1. Enter your domain in the server name field.
  2. Choose the site type: static, single-page app or reverse proxy.
  3. Set the web root, or the upstream URL for a reverse proxy.
  4. Toggle HTTPS, gzip and the www subdomain as needed.
  5. Copy the generated server block into your nginx configuration and reload.

Your data never leaves your device — 100% private processing.

Static sites, SPAs and reverse proxies

The biggest decision is the site type, because it changes the location block. A static site uses try_files $uri $uri/ =404, which serves the requested file or returns a 404 when it is missing. A single-page application instead falls back to /index.html so that deep links like /dashboard are handled by the client-side router rather than returning a server 404. A reverse proxy has no web root at all; it forwards every request to an upstream application server with proxy_pass and sets the headers — Host, X-Real-IP, X-Forwarded-For and X-Forwarded-Proto — that the backend needs to see the original client and protocol. Choosing the right template avoids the two most common nginx mistakes: broken SPA routing and proxied apps that think every visitor is localhost.

Location behaviour by site type
Site typeKey directiveUse for
Statictry_files $uri $uri/ =404Plain HTML/CSS/JS sites
SPAtry_files $uri /index.htmlReact, Vue, Angular apps
Reverse proxyproxy_pass + headersNode, Python, Go backends

HTTPS, gzip and applying the config

Enabling HTTPS does two things: it adds a small server block that listens on port 80 and 301-redirects to https, and it switches the main block to listen on 443 with ssl_certificate directives pointing at a typical Let’s Encrypt path. You still need to obtain the certificate — for example with Certbot — and adjust the paths if yours differ. Gzip compression shrinks text responses such as HTML, CSS, JSON and JavaScript, which improves load time at almost no cost. Once you have the block, save it under /etc/nginx/sites-available and symlink it into sites-enabled, or drop it in conf.d. Always run nginx -t to validate the syntax before reloading with systemctl reload nginx, so a typo never takes your site down.

Worked examples

Static site

Inputs: example.com · static · /var/www/html

Result: server { listen 80; root /var/www/html; try_files $uri $uri/ =404; }

Reverse proxy

Inputs: app.example.com · proxy · http://127.0.0.1:3000

Result: location / { proxy_pass http://127.0.0.1:3000; … }

Glossary

Server block
The nginx equivalent of a virtual host — a block that defines how requests for a domain are handled.
try_files
A directive that tries each listed path in order, used to serve files or fall back to a 404 or index.html.
Reverse proxy
A server that forwards client requests to a backend application and returns its response.
proxy_pass
The directive that tells nginx which upstream URL to forward a request to.
gzip
A compression method nginx can apply to text responses to reduce their transfer size.

Related reading

Frequently Asked Questions

Free · No spam

Get weekly tool tips & updates

New tools, power-user tips, and productivity hacks — delivered free every Friday.

No spam, ever. Unsubscribe with one click.

Why use Nginx Config Generator?

  • Generate a correct nginx server block without memorising directives
  • Templates for static sites, SPAs and reverse proxies
  • Optional HTTPS with an automatic HTTP-to-HTTPS redirect block
  • Adds the proxy headers a reverse proxy actually needs
  • Runs client-side, so your domain and paths never leave the browser

Common use cases

  • Stand up a static website or landing page behind nginx
  • Serve a React, Vue or Angular SPA with client-side routing
  • Put nginx in front of a Node, Python or Go app as a reverse proxy
  • Add a TLS-terminating front end with a clean redirect from HTTP
  • Learn the structure of an nginx server block from a worked example

Related Developer Tools

Explore all Developer Tools.