How to use
- Enter the domain and choose the site type — an upstream address for a reverse proxy, or the web root for the others.
- Tick HTTPS, HTTP/2, HSTS, the www redirect, gzip, caching and security headers as needed.
- Copy or download the config into /etc/nginx/conf.d/, run nginx -t and reload nginx.
Options explained
- Reverse proxy
- Forwards to the upstream address and passes Host, X-Real-IP, X-Forwarded-For and X-Forwarded-Proto, so the backend sees the visitor's real IP and scheme.
- Single-page app
- Unknown paths fall back to index.html, so history-mode routers (React Router, Vue Router) don't 404 on reload.
- HTTPS
- Certificate paths follow certbot's (Let's Encrypt) defaults and HTTP requests get a 301 redirect to HTTPS. HTTP/2 uses the listen 443 ssl http2 form, which works on every nginx version.
- HSTS
- Tells browsers to use only HTTPS for the domain and all its subdomains for a year. Make sure every subdomain supports HTTPS first, or they become unreachable.
Example: single-page app with HTTPS and www
With the domain example.com, Single-page app, HTTPS, HTTP/2 and Also answer www. and redirect it ticked (and Gzip compression, Security headers and Long cache for static files switched off to keep it short), the generator writes three server blocks:
- Port 80 answers both names, keeps
/.well-known/acme-challenge/reachable for certificate renewal and sends everything else tohttps://example.com$request_uriwith a 301. - Port 443 for
www.example.comuses the same certificate and returns a 301 to the bare domain. - Port 443 for
example.comserves the site:
root /var/www/example.com;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
Both HTTPS blocks point at /etc/letsencrypt/live/example.com/fullchain.pem and privkey.pem, allow TLS 1.2 and 1.3 and use a 10 MB shared session cache with a one-day session timeout. The try_files line is what makes a reload on a client-side route such as /settings return the app instead of a 404.
Frequently asked questions
Why does nginx -t warn that the http2 parameter is deprecated?
Since nginx 1.25.1 the separate http2 on; directive is preferred, but 1.24 — shipped with Ubuntu 24.04 and others — doesn't understand it. The listen ... http2 form works everywhere; newer versions only print a warning.
Does the certificate need to include www?
Yes, when the www redirect is on. Request both names, for example certbot -d example.com -d www.example.com.
Uploads fail with 413 Request Entity Too Large?
nginx allows a 1 MB request body by default. Set Max upload size to what you need, such as 100.
WebSocket connections fail through the proxy?
The proxy must forward the Upgrade and Connection headers. Ticking WebSocket support adds them and raises the read timeout to an hour.
Privacy
This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.