Nginx Server Block Generator
Answer a few questions and get a clean, commented Nginx server block you can paste into your configuration. Static site, reverse proxy and PHP-FPM presets included — everything runs in your browser, nothing is uploaded.
/etc/nginx/sites-available/yourdomain, enable it, then run:sudo nginx -tsudo systemctl reload nginx
- Fill in the form — domain, app type and the options you want. The preview updates when you press Generate.
- Copy or download the
serverblock and save it under/etc/nginx/sites-available/, then symlink it intosites-enabled. - Get HTTPS: run
sudo certbot --nginx -d yourdomain.com— Certbot installs a free certificate and fills in the placeholder paths for you. - Validate and reload:
sudo nginx -tmust say "syntax is ok" before you runsudo systemctl reload nginx.
How do I get a free HTTPS certificate for my domain?
Install Certbot on your server and run sudo certbot --nginx -d yourdomain.com. Certbot fetches a free certificate from Let’s Encrypt, installs it, and sets up automatic renewal. The generated config already includes the HTTPS redirect block and placeholder certificate paths that Certbot will fill in.
Should I enable gzip compression?
Yes for almost every site. Gzip shrinks text responses such as HTML, CSS and JavaScript by 60 to 80 percent, which makes pages load noticeably faster, especially on mobile connections. It is disabled for already-compressed formats like images, and it should not be applied to responses that must stay byte-exact.
What proxy headers does the reverse proxy preset set?
The preset sets X-Real-IP and X-Forwarded-For so your app sees the real visitor IP, X-Forwarded-Proto so it knows the original request used HTTPS, and it clears the Connection header for clean HTTP/1.1 keepalive to the backend. It also forwards the Host header unchanged so virtual hosting keeps working.
Can I paste this config into production as it is?
Treat it as a strong starting point, not a finished file. Review the root path, backend address and domain names, run nginx -t to validate the syntax, then reload Nginx. For high-traffic sites you will still want to tune worker counts, timeouts and rate limits to your own load.