Skip to main content

Nginx Server Block Generator

Generate an nginx server block (virtual host) from structured inputs — server name and aliases, listen port, static-file or reverse-proxy mode, SSL/TLS with HTTP→HTTPS redirect and HSTS, gzip compression, client_max_body_size, and access/error log paths. Runs entirely in your browser.

Input

Server

Primary domain for this server block.

Optional. Space-separated additional server names.

Ignored when SSL is enabled (listens on 443 instead).

Mode

Space-separated list.

SSL

Extras

Output

Generated nginx Server Block
 
Was this helpful?

Guides

The Nginx Server Block Generator builds a complete, ready-to-deploy server { } block from a set of structured fields instead of hand-copying a config from an old project and hoping you remembered every directive. Fill in your domain, pick static-file or reverse-proxy mode, toggle SSL, and copy the result straight into /etc/nginx/sites-available/.

What it does

You configure a server block through four groups of settings:

  • Server — primary domain (server_name), optional space-separated aliases (e.g. www.example.com), and the listen port.
  • Mode — either Static files, which sets root and an index directive with a try_files … =404 fallback, or Reverse proxy, which sets proxy_pass to an upstream URL along with the standard Host/X-Real-IP/X-Forwarded-For/X-Forwarded-Proto headers, and an optional toggle to forward the Upgrade/Connection headers WebSocket connections need.
  • SSL — enabling SSL switches the listen directive to 443 ssl (with an http2 flag), fills in ssl_certificate/ssl_certificate_key paths, and adds a sensible TLSv1.2/TLSv1.3 baseline (ssl_prefer_server_ciphers, session cache/timeout). Two companion toggles: a matching HTTP→HTTPS redirect server block, and an HSTS Strict-Transport-Security header — both on by default, since serving a redirect without HSTS still allows the first plaintext request to be intercepted.
  • Extras — gzip compression (with a standard gzip_types list), client_max_body_size (raise this for file-upload endpoints), and access/error log paths.

The output updates live as you edit, and is available via Copy or Download (server-block.conf).

How to use it

  1. Enter your domain in Server Name; add any additional hostnames the same block should answer to in Aliases.
  2. Choose Static files for a plain website or SPA, or Reverse proxy to forward requests to an app server (Node, Python, a container, etc.) running on the same host or network.
  3. Turn on Enable SSL if you have (or will obtain, e.g. via Let's Encrypt) a certificate — this is almost always the right choice for a production domain.
  4. Adjust Client Max Body Size if the site accepts large uploads (nginx's default of 1 MB is often too small).
  5. Copy the result into your nginx config, adjust the certificate/log paths for your server, then reload nginx (nginx -t && systemctl reload nginx).

Why two listen lines?

The generated block always listens on both IPv4 and the IPv6 wildcard (listen [::]:PORT;). Omitting the IPv6 line is a common cause of "works on my machine" bugs on hosts where nginx binds IPv6 by default — dropping it silently leaves IPv6 clients unhandled by this block.

Reverse proxy vs. static files

Static mode is for serving files directly off disk — a built frontend, a documentation site, or anything nginx can hand back without another process involved. Reverse proxy mode is for anything with its own server process (an API, a Node/Python/Ruby app, a container) — nginx terminates the client connection (and SSL) and forwards the request upstream over plain HTTP, which is why the proxy headers matter: without X-Forwarded-Proto, for instance, your backend can't tell whether the original request arrived over HTTPS.

Does this validate my config?

No — this tool assembles the server block from your inputs; it doesn't parse or validate existing nginx configuration. Always run nginx -t before reloading to catch typos or path issues before they affect traffic. For reformatting or re-indenting an existing config file, see the Nginx Config Formatter.

Privacy

Everything runs in your browser. Domain names, certificate paths, and log paths you enter are never sent to a server.

nginxserver blockvirtual hostreverse proxysslconfigweb serverdevops

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.