Dev
Mock Nginx Config Generator
Nginx server block syntax trips up developers who mostly work in application code. The block-and-directive structure, the proxy header conventions, and the static-file location all need to be right for the config to load correctly. This tool generates a sample nginx server block — no inputs required — that includes a listen directive, a server_name with both bare and www variants, a reverse-proxy location, and a static-file location with a 30-day cache expiry. The generated config picks from four realistic domains and four common app ports (3000, 8080, 5000, 4000). The proxy location sets both Host and X-Real-IP headers, which is the standard proxy setup. The static location serves files from /var/www/app with a 30-day expires directive. Copy the output into a new server block file, then replace the domain and proxy port with your own values. Always validate the config with nginx -t before reloading on a live server — a syntax error prevents nginx from starting and will take your site down until you fix it.
How to use
- Choose your options above
- Click Generate
- Copy your result
Detailed instructions
- Click Generate to produce an nginx config.
- Copy it into a server block file.
- Adapt the domain, port, and paths.
- Test the config before reloading.
Use Cases
- •Learning nginx configuration
- •Documenting a server setup
- •Demoing a reverse proxy
- •Seeding example config
- •Testing a config parser
Tips
- →proxy_pass forwards to your app.
- →Serve static files separately.
- →Always test config before reloading.
- →Adapt the domain and ports.
FAQ
what does the generated nginx config include
A server block listening on port 80, a server_name covering both bare and www domains, a root location that proxies to a local app port with Host and X-Real-IP headers, and a /static/ location that serves files from /var/www/app with a 30-day expires. TLS is not included.
what does proxy_pass do and why does it matter
proxy_pass forwards incoming requests to another server — typically your app running on a local port like 3000. Nginx acts as a reverse proxy, handling concerns like TLS termination, header forwarding, and static file serving, while your app focuses on dynamic responses.
does the generator produce TLS or HTTPS configuration
No. The generated config only covers HTTP on port 80. For TLS, you would add a second server block listening on port 443 with ssl_certificate and ssl_certificate_key directives, or use a tool like Certbot to generate and insert those blocks automatically.
how do I test a config before reloading nginx
Run nginx -t (or nginx -T to also print the expanded config). This validates the syntax without actually reloading the server. Only run nginx -s reload after -t exits cleanly — a config error during reload prevents nginx from starting and can take your site offline.
You might also like
Popular tools from other categories that share themes with this one.
Try these next
More free tools from other corners of the catalog, picked by shared themes.