Apache / Nginx Config Generator
Generate Webserver Configurations with SSL, Proxy, PHP, Caching and Security Headers
# HTTP → HTTPS Redirect
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
# Let's Encrypt ACME challenge
location /.well-known/acme-challenge/ {
root /var/www/html;
}
location / {
return 301 https://$host$request_uri;
}
}
# www → non-www Redirect
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256;
ssl_prefer_server_ciphers off;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
return 301 https://example.com$request_uri;
}
# Main server block
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
root /var/www/html;
index index.html index.htm;
# SSL/TLS
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256;
ssl_prefer_server_ciphers off;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
# 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 Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" 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/rss+xml application/atom+xml image/svg+xml;
# Logging
access_log /var/log/nginx/example.com.access.log combined;
error_log /var/log/nginx/example.com.error.log warn;
# Static files
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|webp|woff2?|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
location / {
try_files $uri $uri/ /index.html;
}
}ln -s /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/nginx -t && systemctl reload nginxa2ensite example.com.confapache2ctl configtest && systemctl reload apache2certbot --nginx -d example.com# or: certbot --apacheEffortless Web Server Configuration
The Apache and Nginx Config Generator simplifies the process of creating production-ready web server configurations. By providing specific details such as your domain name, document root, and PHP-FPM socket paths, the tool automatically generates the necessary configuration files. It supports both Apache and Nginx environments, allowing you to quickly set up SSL/TLS certificates, proxy settings, and security headers without manually editing complex configuration files or worrying about syntax errors during the initial setup phase.
Advanced Features for Modern Web Hosting
This tool includes built-in support for essential modern web features like browser caching for assets, custom log directories, and seamless integration with Let's Encrypt certificates. You can easily enable SSL/TLS to secure your site and configure proxy rules for backend applications. By automating the generation of these components, you ensure that your server is optimized for performance and security from the start, reducing the risk of common configuration mistakes in your production environment.
Frequently asked questions
How do I generate an Nginx config with SSL?
Provide your domain name and the paths to your .crt and .key files in the tool. The generator will then produce a complete Nginx configuration including SSL/TLS activation, ensuring your website is served over a secure connection while automatically incorporating necessary security headers for better protection.
Can I use this tool to configure PHP-FPM?
Yes, the generator includes a specific field for your PHP-FPM socket path. By entering the correct path, the tool will generate both Apache and Nginx configurations that correctly route PHP requests through the FPM processor, ensuring your dynamic content loads correctly on your server.
Does the tool support Let's Encrypt?
The tool includes a specific option for Let's Encrypt certificates and provides the corresponding certbot commands for Apache. This helps you quickly transition from manual certificate management to automated tools while still providing the underlying configuration needed for your web server to recognize the certificates correctly.
Is my data safe when using this tool?
Yes, since this is a browser-based tool, all calculations and configurations are processed locally in your browser. Your sensitive information, such as certificate paths or internal server details, is never sent to an external server, ensuring that your private configuration data remains completely private and secure at all times.