Dev
Nginx Config Snippet Generator
Used by developers, writers, and creators worldwide.
An nginx config snippet generator gives you a correct server block for the task at hand, so you can configure a web server without trawling old projects for the right directives. Choose a snippet — a reverse proxy to an app server, a cached static site, an HTTP to HTTPS redirect, or a single-page-app fallback — and it returns a clean block with the headers and directives that each pattern needs, like the X-Forwarded headers a proxy must forward or the try_files fallback an SPA relies on for client-side routing. Developers and sysadmins use it to set up a site, recall proxy headers, or teach nginx structure. It runs in your browser and generates instantly. Drop the block into your sites-available config, change the server_name and paths to match your setup, then test with nginx -t before reloading. Each snippet captures a known-good pattern so routing and caching just work.
Read the complete guide — 4 min read
Loading usage…
Free forever — no account required
How to use
- Choose your options above
- Click Generate
- Copy your result
Detailed instructions
- Pick the snippet you need.
- Click Generate to produce the server block.
- Edit server_name and paths to match your setup.
- Run nginx -t, then reload nginx.
Use Cases
- •Setting up a reverse proxy to an app server
- •Serving a static site with sensible caching
- •Redirecting all HTTP traffic to HTTPS
- •Adding client-side routing fallback for an SPA
- •Recalling the proxy headers nginx must forward
Tips
- →Always run nginx -t before reloading to catch typos.
- →Terminate TLS with the HTTPS redirect plus a 443 server block.
- →Set long cache headers on hashed static assets.
- →Keep one server block per file in sites-available.
FAQ
why forward the X-Forwarded headers
Behind a proxy, your app sees nginx as the client unless you forward the original details. The X-Real-IP and X-Forwarded-For headers carry the real client address, and X-Forwarded-Proto tells the app the request was HTTPS.
what does the SPA try_files line do
It serves a real file if it exists, otherwise falls back to index.html so the single-page app can handle the route in JavaScript. Without it, deep links to client-side routes return a 404 on refresh.
how do I test the config safely
Run nginx -t to validate the syntax before applying, then reload with nginx -s reload or your service manager. Testing first means a typo never takes the running server down.
You might also like
Popular tools from other categories that share themes with this one.