How to use the Nginx Config Generator
- 1. Enter domainsList the domain and its www version, and choose the one you prefer.
- 2. Choose the site typeReverse proxy to an app, a static folder, or a single-page app.
- 3. Install and testSave the file, run sudo nginx -t, then reload Nginx.
What the defaults produce
For example.com and www.example.com with HTTPS and the bare domain preferred, you get three server blocks. The first listens on port 80 and sends everyone to https://example.com$request_uri with a 301. The second catches https://www and redirects it to the bare domain. The third is the real site: it listens on 443 with http2 on;, points to Let's Encrypt certificates under /etc/letsencrypt/live/example.com/, allows TLS 1.2 and 1.3, turns on gzip and adds four security headers.
Its location block uses proxy_pass http://127.0.0.1:3000; and passes Host, X-Real-IP, X-Forwarded-For and X-Forwarded-Proto so your app sees the real visitor, plus the Upgrade headers WebSockets need.
Static sites and single-page apps
- Static serves files from the web root and returns 404 for missing paths.
- Single-page app falls back to /index.html, so React, Vue or Angular routes work after a refresh.
- Both cache CSS, JS, images and fonts for 30 days and stop logging those requests.
Get the certificate before you enable the HTTPS blocks, for example with certbot. The http2 on; directive needs nginx 1.25.1 or newer; on older versions put http2 on the listen line instead. HSTS tells browsers to use HTTPS for a year, so add it only once HTTPS works. Analyse traffic afterwards with the access log analyzer, and add a Content Security Policy header when you are ready.
Frequently asked questions
Where do I put the file?
On Debian and Ubuntu, /etc/nginx/sites-available/ with a link in sites-enabled. On other systems, /etc/nginx/conf.d/yourdomain.conf.
Why does the upload size setting matter?
Nginx rejects request bodies over client_max_body_size with 413 Request Entity Too Large. Raise it if users upload big files.
Is the Nginx Config Generator free?
Yes, the Nginx Config Generator is free. The first time you generate your first config, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.