nginx Config Generator
Generate nginx server block configurations for static sites, PHP apps, WordPress, or reverse proxy.
📦 Config Type
🌐 Domain Settings
🔒 SSL Settings
⚙️ Additional Options
# Generated by Repo - nginx Config Generator
# https://repo.pk
# HTTP to HTTPS Redirect
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}
# Main Server Block
server {
listen 443 ssl http2;
server_name example.com;
root /var/www/html;
index index.html index.php;
# SSL Configuration
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
# Security Headers
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;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# GZIP Compression
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;
# Static File Caching
location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff|woff2|ttf|svg|webp)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
location / {
try_files $uri $uri/ =404;
}
# Deny access to hidden files
location ~ /\. {
deny all;
}
}Features
- Static, PHP, WordPress, Proxy configs
- SSL/HTTPS support
- GZIP compression
- Security headers
- Browser caching
- WebSocket support
How to Use
- 1Select config type
- 2Enter domain and paths
- 3Configure SSL if needed
- 4Copy and deploy to server
Frequently Asked Questions
Where do I put this config?
Save as /etc/nginx/sites-available/yourdomain and symlink to sites-enabled.
How do I get SSL certificates?
Use Let's Encrypt with certbot: sudo certbot --nginx -d yourdomain.com