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
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
rootand anindexdirective with atry_files … =404fallback, or Reverse proxy, which setsproxy_passto an upstream URL along with the standardHost/X-Real-IP/X-Forwarded-For/X-Forwarded-Protoheaders, and an optional toggle to forward theUpgrade/Connectionheaders WebSocket connections need. - SSL — enabling SSL switches the listen directive to
443 ssl(with anhttp2flag), fills inssl_certificate/ssl_certificate_keypaths, and adds a sensibleTLSv1.2/TLSv1.3baseline (ssl_prefer_server_ciphers, session cache/timeout). Two companion toggles: a matching HTTP→HTTPS redirect server block, and an HSTSStrict-Transport-Securityheader — 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_typeslist),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
- Enter your domain in Server Name; add any additional hostnames the same block should answer to in Aliases.
- 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.
- 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.
- Adjust Client Max Body Size if the site accepts large uploads (nginx's default of 1 MB is often too small).
- 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.