nginx Config Builder
Build nginx server blocks and location blocks with a visual form. Configure reverse proxy, static file serving, WebSocket, CORS, gzip, and security headers — then copy the generated config.
Server Block
Location Block Options
Generated nginx Config
Frequently Asked Questions
What is the difference between a server block and a location block?▼
A server block defines a virtual host — it listens on a port and matches a domain name. A location block lives inside a server block and matches request paths (e.g. /api/, /static/). You can have multiple location blocks per server block to route different paths to different backends or apply different rules.
When should I use proxy_pass vs alias vs root?▼
Use proxy_pass to forward requests to a backend (Node.js, Python, etc.). Use root to set the base directory for serving static files — the full path is root + URI. Use alias to map a location path to a different filesystem path, replacing the location prefix rather than appending to root.
What does proxy_set_header X-Real-IP do?▼
When nginx acts as a reverse proxy, it forwards requests to your backend. Without extra headers, the backend sees nginx's address, not the real client IP. proxy_set_header X-Real-IP $remote_addr passes the original client IP. Use $http_x_forwarded_for if there's a load balancer in front of nginx.
How do I handle WebSocket connections in nginx?▼
WebSocket upgrades require two extra headers: proxy_set_header Upgrade $http_upgrade and proxy_set_header Connection 'upgrade'. Also set proxy_http_version 1.1 since WebSockets require HTTP/1.1. Without these, nginx closes the connection and WebSocket handshake fails.
What is try_files and when do I use it?▼
try_files checks a list of files/paths in order. try_files $uri $uri/ /index.html is the classic SPA pattern: try the exact file, then a directory index, then fall back to index.html. This enables client-side routing for React, Vue, Angular apps served from nginx.
How do I apply these config snippets?▼
Place snippets in /etc/nginx/sites-available/mysite.conf. Then enable: sudo ln -s /etc/nginx/sites-available/mysite.conf /etc/nginx/sites-enabled/. Test: sudo nginx -t. Reload: sudo systemctl reload nginx. On some systems, you include from /etc/nginx/conf.d/ instead.
Related Products
on GumroadPremium Workflow Pack
Production-grade workflows, architecture guides, and deployment scripts for teams that ship. 10 advanced CI/CD workflows (blue-green, canary, E2E, security), 5 architecture deep-dives, code review checklist, PR process guide, and 5 battle-tested Bash deployment scripts.
Buy on Gumroad →GitHub Actions CI/CD Templates Pack
12 production-ready GitHub Actions workflow templates covering Node.js, Python, Docker, multi-environment deployments, security scanning, and auto-changelog. Copy, paste, ship.
Buy on Gumroad →Developer Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →You Might Also Need
nginx Config Generator
Generate production-ready nginx server blocks instantly. Supports static sites, reverse proxy (Node.js, API), PHP-FPM, and HTTPS redirects. Includes SSL/TLS, gzip, cache headers, security headers, and
Open free tool →
Haproxy Config Validator
Haproxy Config Validator — developer tool on DevPlaybook.
Open free tool →
Caddy Caddyfile Generator
Caddy Caddyfile Generator — developer tool on DevPlaybook.
Open free tool →
More Free Tools
Related Articles
Nginx Configuration Guide for Web Developers 2026: Reverse Proxy, SSL & Performance
Master Nginx configuration in 2026. Complete guide covering reverse proxy setup, SSL/TLS with Let's Encrypt, gzip compression, caching, rate limiting, load balancing, and common gotchas.
Nginx vs Caddy vs Traefik vs HAProxy: Web Server & Reverse Proxy Comparison 2025
A comprehensive comparison of Nginx, Caddy, Traefik, and HAProxy. Performance benchmarks, SSL/TLS handling, configuration syntax, Docker/K8s integration, and when to use each.
Nginx Config Generator: Stop Writing Server Blocks by Hand
Learn how to use an Nginx config generator to create reverse proxies, SSL configs, load balancers, and virtual hosts instantly. Includes real examples and best practices.
Complete Guide to HTTP Security Headers: CSP, HSTS, and Modern Browser Security 2026
Master HTTP security headers in 2026: Content-Security-Policy configuration, HSTS preloading, Permissions-Policy, COEP/COOP for cross-origin isolation, and real-world configs for nginx, Apache, and Next.js.
DevOps Automation Tools in 2026: Orchestrating the Software Delivery Pipeline
Master DevOps automation with this guide to the tools that orchestrate modern software delivery. Covers CI/CD pipelines, infrastructure provisioning, configuration management, testing automation, and the emerging AI-assisted automation patterns that define 2026.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →