Embed this tool on your site
<iframe src="https://devtoolbox.dedyn.io/tools/nginx-config-generator" width="100%" height="900" frameborder="0" title="Nginx Config Generator"></iframe>

Nginx Config Generator

Build production-ready Nginx configuration files visually. Select a preset, configure server settings, SSL, locations, gzip, rate limiting, caching, and more. The config updates in real time. Ctrl+Enter to generate, Ctrl+Shift+C to copy.

Presets:

Server Settings

Location Blocks

Custom Headers

Compression & Performance

Rate Limiting

Logging

Generated nginx.conf

# Click "Generate Config" or press Ctrl+Enter

Frequently Asked Questions

What is an Nginx server block?
An Nginx server block (similar to Apache's VirtualHost) defines the configuration for a specific domain or IP address. Each server block contains directives like listen, server_name, root, and location blocks that control how Nginx handles requests. You can have multiple server blocks to host several websites on one server.
How do I configure Nginx as a reverse proxy?
To configure Nginx as a reverse proxy, use the proxy_pass directive inside a location block. For example: location / { proxy_pass http://127.0.0.1:3000; }. You should also set proxy_set_header directives for Host, X-Real-IP, X-Forwarded-For, and X-Forwarded-Proto to pass client information to the backend.
How do I set up SSL/TLS in Nginx?
To enable SSL, add listen 443 ssl to your server block and specify ssl_certificate and ssl_certificate_key paths. Configure ssl_protocols (TLSv1.2 TLSv1.3), enable HSTS with add_header Strict-Transport-Security, and set up OCSP stapling. Create a separate server block on port 80 to redirect HTTP to HTTPS.
What is the try_files directive in Nginx?
The try_files directive tells Nginx to check for files in a specific order and serve the first one found. For example, try_files $uri $uri/ /index.html means: try the exact URI, then the URI as a directory, then fall back to /index.html. This is essential for single-page applications (SPAs) like React, Vue, or Angular.
How do I enable gzip compression in Nginx?
Enable gzip by adding gzip on; to your server block. Configure gzip_types to specify which MIME types to compress (text/plain, text/css, application/javascript, application/json, etc.), set gzip_min_length to skip small files, and use gzip_vary on to send the Vary: Accept-Encoding header for proper caching.