Nginx Config Generator
Build a complete nginx server block from simple toggles, live in your browser. Your inputs stay on your device.
Your domain, paths, and certificate locations are used only in your browser to build the config, which is never uploaded. Still, avoid pasting real private-key contents into any tool.
Need file permissions for your web root? Try the Chmod Calculator.
About Nginx Config Generator
This nginx config generator turns a handful of inputs and toggles into a complete, valid nginx server block you can drop into sites-available. Pick a static site (root + index with try_files) or a reverse proxy (proxy_pass with the standard Host, X-Real-IP, X-Forwarded-For, and X-Forwarded-Proto headers, plus optional WebSocket upgrade lines). Flip on SSL to listen on 443, wire up ssl_certificate and ssl_certificate_key, and emit a second server block that 301-redirects HTTP to HTTPS. Add gzip, long-lived static asset caching, a client_max_body_size limit, and a canonical www-to-non-www redirect with one click each. As an nginx config generator it keeps braces balanced and indentation clean, then lets you copy the result or download it as <domain>.conf. Everything runs in your browser, so your domain and paths stay on your device.
Features
- Static site mode with root, index, and a try_files location block
- Reverse proxy mode with proxy_pass and standard proxy_set_header lines
- Optional WebSocket support via proxy_http_version, Upgrade, and Connection headers
- SSL toggle that adds listen 443 ssl plus an HTTP→HTTPS 301 redirect server
- gzip block tuned for text, JSON, JavaScript, CSS, XML, and SVG
- Static asset caching location with expires and immutable Cache-Control
- client_max_body_size input and www↔non-www canonical redirects
- Copy the server block or download it as example.com.conf
How to use the Nginx Config Generator
- Enter your domain and listen port, and choose static site or reverse proxy.
- Fill in the root and index, or the proxy_pass upstream for your app.
- Toggle SSL, gzip, caching, body size, and a www redirect as needed.
- Read the live nginx config on the right, then Copy or Download the .conf.
Example
Input
Domain: example.com
Mode: Reverse proxy
Upstream: http://127.0.0.1:3000
SSL: on
Output
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name example.com www.example.com;
ssl_certificate /etc/ssl/certs/example.com.crt;
ssl_certificate_key /etc/ssl/private/example.com.key;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 301 https://$host$request_uri;
}
A reverse proxy on 443 with the matching HTTP→HTTPS redirect block.
Common errors & troubleshooting
- nginx -t reports "cannot load certificate" or the SSL block fails to start. — Point ssl_certificate at your fullchain file and ssl_certificate_key at the matching private key, and make sure both paths exist and are readable by nginx.
- A reverse-proxied app shows the wrong client IP or breaks behind HTTPS. — Keep the generated proxy_set_header lines so Host, X-Real-IP, X-Forwarded-For, and X-Forwarded-Proto reach your upstream, and read them from the right headers in your app.
- WebSocket connections drop with a 400 or fail to upgrade. — Turn on WebSocket support so the location adds proxy_http_version 1.1 with the Upgrade and Connection "upgrade" headers nginx needs to proxy ws/wss.
- Large uploads return 413 Request Entity Too Large. — Set client_max_body_size to a value above your largest upload, for example 20M or 100M, and reload nginx.
Frequently asked questions
- How do I set up a reverse proxy in nginx?
- Choose Reverse proxy, enter your upstream in proxy_pass (for example http://127.0.0.1:3000), and the generator adds a location / block with the standard Host, X-Real-IP, X-Forwarded-For, and X-Forwarded-Proto headers. Enable WebSocket support if your app uses ws/wss.
- Where do nginx server blocks live?
- On Debian and Ubuntu, save the generated file as /etc/nginx/sites-available/example.com and symlink it into sites-enabled. On many other distros, drop it in /etc/nginx/conf.d/example.com.conf, then run nginx -t and reload.
- How does the SSL toggle change the config?
- It switches the main server to listen on 443 ssl, adds ssl_certificate and ssl_certificate_key, and emits a second server block on port 80 that 301-redirects every request to https://, so visitors always land on the secure site.
- What is the difference between a static site and a reverse proxy here?
- Static mode serves files from a root directory with index and a try_files location, ideal for HTML, SPAs, or built assets. Reverse proxy mode forwards requests to an upstream app server with proxy_pass and proxy headers instead of serving files.
- Can I add gzip and static asset caching?
- Yes. The gzip toggle adds a tuned gzip block for text, JSON, JavaScript, CSS, XML, and SVG, and the caching toggle adds a location that sets a 30-day expires and an immutable Cache-Control header for common asset extensions.
- Is my domain or config sent anywhere?
- No. This nginx config generator runs entirely in your browser, so the domain, paths, and certificate locations you type are processed on your device and the generated file is never uploaded.
Related tools
All ArrayKit tools