Last updated
Why Use the Apache Config Generator
- Production-ready SSL — TLS 1.2/1.3 only, secure cipher suites, HSTS, OCSP stapling
- Security headers — CSP, X-Frame-Options, HSTS, and more generated correctly
- Reverse proxy — Node.js, Python, Java backend proxying with WebSocket support
- Redirect patterns — HTTP to HTTPS, www to non-www, URL migrations
- Performance — gzip compression and browser caching configured correctly
- No memorization — generates correct directive syntax without needing to look it up
Use the Apache Config Generator at TechConverter.me to create correct, secure Apache configurations without memorizing complex directive syntax or researching current SSL best practices.
Examples
Example 1: HTTPS Virtual Host with SSL
# HTTP — redirect all traffic to HTTPS
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
Redirect permanent / https://example.com/
</VirtualHost>
# HTTPS — main virtual host
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public
# SSL Configuration
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
# Modern SSL protocols only
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256
SSLHonorCipherOrder off
SSLSessionTickets off
# OCSP Stapling
SSLUseStapling on
SSLStaplingCache shmcb:/var/run/ocsp(128000)
# Security Headers
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
Header always set X-Frame-Options "DENY"
Header always set X-Content-Type-Options "nosniff"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
<Directory /var/www/example.com/public>
Options -Indexes +FollowSymLinks
AllowOverride None
Require all granted
</Directory>
ErrorLog /var/log/apache2/example.com-error.log
CustomLog /var/log/apache2/example.com-access.log combined
</VirtualHost>
Example 2: Reverse Proxy to Node.js Application
<VirtualHost *:443>
ServerName api.example.com
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/api.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/api.example.com/privkey.pem
# Proxy to Node.js on port 3000
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
# Pass real IP to backend
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Real-IP %{REMOTE_ADDR}s
# WebSocket support
RewriteEngine On
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://127.0.0.1:3000/$1" [P,L]
</VirtualHost>
Example 3: URL Redirects
# Redirect www to non-www (permanent 301)
<VirtualHost *:443>
ServerName www.example.com
Redirect permanent / https://example.com/
</VirtualHost>
# Redirect old URLs to new URLs
RewriteEngine On
RewriteRule ^/old-page/?$ /new-page [R=301,L]
RewriteRule ^/blog/(.+)$ /articles/$1 [R=301,L]
RewriteRule ^/products/(.+)$ /shop/$1 [R=301,L]