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
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.
- Enter your domain in the server name field.
- Choose the site type: static, single-page app or reverse proxy.
- Set the web root, or the upstream URL for a reverse proxy.
- Toggle HTTPS, gzip and the www subdomain as needed.
- 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.
| Site type | Key directive | Use for |
|---|---|---|
| Static | try_files $uri $uri/ =404 | Plain HTML/CSS/JS sites |
| SPA | try_files $uri /index.html | React, Vue, Angular apps |
| Reverse proxy | proxy_pass + headers | Node, 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
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
.htaccess Redirect Generator
Generate .htaccess redirect rules online. Create 301/302 redirects, www and HTTPS forcing, and RewriteRule snippets for Apache. Free and private.
robots.txt Generator
Generate a robots.txt file for your website. Set user-agents, allow/disallow rules, crawl-delay, and sitemap URL. Free, private robots.txt builder.
docker run to docker-compose
Convert a docker run command into a docker-compose.yml service. Parses ports, env vars, volumes, restart, networks and more — instant and private in your browser.
JSON Formatter & Validator
Format, validate, and minify JSON instantly. Includes syntax highlighting, error detection, and a collapsible tree view — free, private, in-browser.
Regex Tester
Test and debug regular expressions online. See live matches, capture groups, and replace output. Free, private, instant.
Base64 Encoder & Decoder
Encode text or files to Base64, or decode Base64 strings back to text. Fast, free, and runs entirely in your browser.
Explore all Developer Tools.