Nginx Config Generator
Generate production-ready nginx.conf files
for static sites, Node.js apps, PHP, WordPress, Laravel, and SPAs — with SSL, gzip, caching, and
reverse proxy.
Quick Presets
Global Settings
Server Block #1
Generated nginx.conf
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
client_max_body_size 16m;
server_tokens off;
server {
listen 80;
server_name example.com www.example.com;
root /var/www/html;
index index.html index.htm;
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml image/svg+xml;
gzip_min_length 256;
gzip_comp_level 6;
location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff2|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
location / {
try_files $uri $uri/ =404;
}
location ~ /\.ht {
deny all;
}
}
} nginx -t before reloading.About Nginx Config Generator
The Nginx Config Generator is a free online tool that helps web developers and
system administrators create production-ready nginx.conf files without writing configuration from scratch. Whether you're deploying a static site, a Node.js
application, a PHP project, or a WordPress installation, this tool generates correct, well-structured
Nginx configuration in seconds.
Nginx is one of the world's most popular web servers and reverse proxies, powering over 30% of all websites globally. Its configuration language is powerful but can be complex — especially when combining SSL termination, gzip compression, caching headers, PHP-FPM integration, and reverse proxy rules all in one file.
How to Use the Nginx Config Generator
- 1. Choose a Preset — Select a quick preset matching your use case: Static Site, SPA (React/Vue), Node.js, PHP, WordPress, or Laravel. The tool instantly configures sensible defaults.
- 2. Configure Global Settings — Adjust
worker_processes,worker_connections, keepalive timeout, and max upload size. - 3. Set Up Your Server Block — Enter your domain name(s), document root path, index files, and listen port. Toggle SSL, gzip, static caching, PHP-FPM, or reverse proxy as needed.
- 4. Add SSL Details — If SSL is enabled, enter your certificate and key paths (e.g., Let's Encrypt paths). Enable HTTP → HTTPS redirect automatically.
- 5. Add Custom Locations — Use the "Add Location" button to define custom
locationblocks for specific paths — proxy to a microservice, serve static files from a CDN alias, redirect old URLs, or deny access to sensitive paths. - 6. Copy or Download — Click "Copy" to copy to clipboard, or "Download" to
save as
nginx.conf. - 7. Test and Reload — On your server, run
nginx -tto validate, thensystemctl reload nginxto apply.
Frequently Asked Questions
What is an Nginx config file?
An Nginx configuration file (nginx.conf)
defines how Nginx handles incoming HTTP/HTTPS requests — which ports to listen on, where
files are served from, how to pass requests to backend applications, and what headers to
send. It uses a block-based syntax with directives like server, location, and upstream.
Where is the nginx.conf file located?
The default location is /etc/nginx/nginx.conf on most Linux distributions. Individual site configs are often placed in /etc/nginx/sites-available/ and symlinked
from /etc/nginx/sites-enabled/. On
macOS with Homebrew, the path is typically /usr/local/etc/nginx/nginx.conf.
How do I enable SSL with Let's Encrypt?
First, run certbot --nginx -d example.com to obtain a certificate. Certbot will create cert files at /etc/letsencrypt/live/example.com/.
Enable SSL in this generator, enter those paths, and check "Redirect HTTP → HTTPS". Let's
Encrypt certificates auto-renew via a cron job installed by Certbot.
What is the difference between proxy_pass and fastcgi_pass?
proxy_pass forwards HTTP requests to
another web server or application (like a Node.js or Python process running on a port). fastcgi_pass uses the FastCGI protocol,
which is specifically used to communicate with PHP-FPM. Use proxy_pass for most modern apps
and fastcgi_pass exclusively for PHP.
How do I serve a React or Vue SPA with Nginx?
Select the "SPA" preset. The key directive is try_files $uri $uri/ /index.html,
which tells Nginx to serve your index.html for any path not found on disk — this lets client-side routing (React Router, Vue Router)
handle the URL. Make sure your build output folder is set as the root.
How do I test if my Nginx config is valid?
Run sudo nginx -t on your server.
If the config is valid, you'll see "syntax is ok" and "test is successful". To apply
changes without downtime, use sudo systemctl reload nginx (or sudo nginx -s reload). Never use
restart unless necessary, as reload does a graceful reload with zero dropped connections.
Should I use worker_processes auto?
Yes, in almost all cases. Setting worker_processes auto tells Nginx to
automatically detect the number of CPU cores and spawn one worker per core, which is the
optimal setting for most workloads. Only override this manually if you need to restrict CPU
usage intentionally.
Is this tool free and does it store my config?
This tool is completely free to use. All configuration generation happens in your browser — nothing is sent to or stored on any server. Your domain names, file paths, and settings remain entirely private on your device.