Nginx Config Generator
Generate production-ready Nginx configuration files for reverse proxy, static sites, SSL, and load balancing.
How to Use the Nginx Config Generator
- Choose a mode — select Reverse Proxy, Static Site, SSL, or Load Balancer using the chips above.
- Fill in the fields — enter your domain, ports, paths, and backend addresses.
- Copy or download — use the buttons above the output to copy or save as nginx.conf.
- Test and deploy — run
nginx -tto validate before reloading:nginx -s reload.
Understanding Nginx Configuration Modes
Nginx is one of the most versatile pieces of infrastructure software available. A single Nginx instance can simultaneously serve static files at blazing speed, proxy API requests to a Node.js or Python backend, terminate SSL certificates from Let's Encrypt, and distribute load across a cluster of application servers. Understanding which mode to use for each scenario is the key to getting the most out of Nginx.
Reverse Proxy Configuration
A reverse proxy sits in front of your application server and forwards incoming HTTP requests to it. This is the most common Nginx use case for modern web applications. When you deploy a Node.js app on port 3000, a Django app on port 8000, or any other backend service, Nginx acts as the public-facing entry point on port 80 or 443. The generated config includes the essential proxy headers: X-Real-IP passes the client's real IP address, X-Forwarded-For maintains the full proxy chain, and the Host header ensures your application sees the correct domain. Without these headers, your application will log all requests as coming from 127.0.0.1 and may misbehave when generating redirects or links.
Static Site Configuration
For sites that serve pre-built HTML, CSS, JavaScript, and image files, the static site configuration is optimal. Nginx is extraordinarily efficient at serving static files — it uses kernel-level sendfile() to transfer files directly from disk to network without copying data through user space. The generated config includes try_files for single-page application routing (so that refreshing /about returns index.html instead of a 404), gzip compression to reduce transfer sizes by 60-80% for text content, and cache-control headers that tell browsers to cache static assets for up to one year.
SSL / TLS Configuration
The SSL mode generates a configuration using TLS 1.2 and 1.3 only — TLS 1.0 and 1.1 are disabled because they are vulnerable to attacks like POODLE and BEAST. The cipher suite is set to the Mozilla Intermediate compatibility profile, which balances security with broad client support. HSTS (HTTP Strict Transport Security) instructs browsers to always use HTTPS for your domain, preventing downgrade attacks. If you use Let's Encrypt, the certificate paths follow the standard Certbot layout under /etc/letsencrypt/live/yourdomain.com/.
Load Balancer Configuration
The load balancer mode generates an upstream block with multiple backend servers. Round-robin is the default and distributes requests evenly across all healthy backends. least_conn sends each new request to the backend with the fewest active connections — better for backends with uneven processing times. ip_hash pins each client IP to a specific backend, useful for applications with server-side sessions. For production use, add health_check directives (Nginx Plus) or use the open-source nginx_upstream_check_module to detect and remove failed backends automatically.
Testing and Deploying Nginx Configs
Always test your configuration before reloading: sudo nginx -t. This validates syntax and checks that referenced files exist. To apply changes without dropping connections, use sudo nginx -s reload — this sends a SIGHUP signal that gracefully restarts worker processes. For large deployments, consider Docker Compose with Nginx as the reverse proxy container, which makes configuration changes reproducible and version-controlled.