Azlaan Electric AC Solar Center — Solar, CCTV, AC & electrical work, Faisalabad Call: 0300-8987448

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.

Your site details
Please enter a valid domain, for example example.com.
Host and port your app listens on.
Check your PHP version: ls /var/run/php/
Options
Generated config

                        
Test before you reload
Save the file as /etc/nginx/sites-available/yourdomain, enable it, then run:
sudo nginx -t
sudo systemctl reload nginx
If the test reports an error, fix it first — a bad reload can take every site on the server offline.
How to use it
  1. Fill in the form — domain, app type and the options you want. The preview updates when you press Generate.
  2. Copy or download the server block and save it under /etc/nginx/sites-available/, then symlink it into sites-enabled.
  3. Get HTTPS: run sudo certbot --nginx -d yourdomain.com — Certbot installs a free certificate and fills in the placeholder paths for you.
  4. Validate and reload: sudo nginx -t must say "syntax is ok" before you run sudo systemctl reload nginx.
Frequently asked questions

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.