Nginx Config Generator
Generate production-ready Nginx configurations — static sites, SPAs, reverse proxies, and PHP apps
nginx.conf
server {
listen 80;
server_name example.com;
client_max_body_size 10m;
root /var/www/html;
index index.html;
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript image/svg+xml;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
location / {
try_files $uri $uri/ =404;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, immutable";
}
location ~ /\. {
deny all;
}
}Nginx Config Generator
Generate production-ready Nginx configurations — static sites, SPAs, reverse proxies, and PHP apps
Features
- Four server types: static, SPA, reverse proxy, PHP
- SSL/TLS configuration with modern cipher suites
- Gzip compression with optimized settings
- Static asset caching with immutable headers
- Security headers (X-Frame-Options, HSTS, etc.)
- www to non-www redirect
- WebSocket proxy support
- 100% client-side generation
How to use
- Select your server type (static, SPA, reverse proxy, or PHP).
- Enter your domain name and configure paths.
- Toggle features like SSL, gzip, caching, and security headers.
- Copy the generated config and save it to your server.
Tips & Best Practices
- Always enable security headers in production.
- Use 'certbot' (Let's Encrypt) to get free SSL certificates.
- For SPAs, the try_files fallback to index.html is essential for client-side routing.
FAQ
What is the difference between static and SPA mode?
Static mode returns 404 for unknown paths. SPA mode redirects all paths to index.html, enabling client-side routing (React, Angular, Vue).
Should I enable gzip?
Yes, gzip compression reduces file sizes by 60-80% and significantly improves page load times.
How do I set up SSL?
Enable SSL, provide your certificate and key paths, and the generator will create an HTTP-to-HTTPS redirect block automatically.