A minimal, working static-site server block
For server_name www.example.com with root /var/www/html and no PHP-FPM, the generator produces a complete server block: listen 80;, the server_name and root directives, index index.html;, and a location / block with try_files $uri $uri/ =404;.
try_files $uri $uri/ =404; is doing real work here, not boilerplate -- it tells Nginx to first try serving the exact requested file, then try it as a directory (looking for an index file inside), and only return a 404 if neither exists. Without this directive, Nginx would need a different fallback strategy for handling missing files or directory requests.
This block listens on port 80 (plain HTTP) only -- it's a deliberately minimal starting point meant to be extended with TLS configuration before serving real production traffic over HTTPS.
What toggling PHP-FPM would add, and what's still missing
Starter server {} only. TLS, upstreams, and rate limits are not generated. Setting the PHP-FPM option to yes would add a location ~ \.php$ block routing PHP requests to a FastCGI socket or upstream -- necessary for WordPress or any PHP application, but omitted here since this example uses a static-site configuration.
This is a single server {} block for one domain -- real production Nginx configs frequently need TLS (a separate server block on port 443 with certificate paths, often alongside a port-80 block that just redirects to HTTPS), upstream blocks for reverse-proxying to an application server, and rate-limiting directives, none of which this starter generates.
Nginx config syntax is strict about semicolons and brace matching -- a config built up manually by copy-pasting from multiple sources is a common source of syntax errors; a generator like this at least guarantees valid syntax for the specific directives it includes.
Extending this into a production config
Adding TLS termination, security headers, and CORS behavior are common next steps after this starter block -- see the CSP Header Builder and CORS Header Generator for the header side of that hardening.
If the target server actually runs Apache instead, the Nginx to Apache Config Converter translates directives between the two.
Frequently Asked Questions (FAQ)
What does try_files $uri $uri/ =404; actually do?
It tells Nginx to try serving the request path as a file first, then as a directory (checking for an index file), and only return a 404 error if neither the file nor the directory exists -- this is the standard pattern for serving a static site correctly.
Does this generate an HTTPS-ready config?
No. Starter server {} only. TLS, upstreams, and rate limits are not generated. This block listens on port 80 only. Adding TLS requires a separate server block (or additional directives) with certificate paths and typically a redirect from port 80 to port 443, none of which this starter includes.
What changes if I enable the PHP-FPM option?
It adds a location block matching .php file requests and routes them to a PHP-FPM socket or upstream via FastCGI -- required for running WordPress or any PHP-based application, since without it Nginx would just try to serve .php files as static text rather than executing them.
Is this a complete production-ready configuration?
No, it's a minimal, syntactically valid starting point. Real production configs typically add TLS, security headers, gzip/caching rules, and possibly reverse-proxy upstream blocks -- this generator covers the base server block only.
Why does Nginx config syntax matter so much (semicolons, braces)?
Nginx's config parser is strict -- a missing semicolon or mismatched brace will cause the entire config (or that server block) to fail to load, potentially taking down the site. A generator that guarantees correct syntax for the directives it produces removes that specific risk.