SSL/TLS Configuration in Apache

From the Apache cheat sheet ยท Virtual Hosts ยท verified Jul 2026

SSL/TLS Configuration

Configuring HTTPS with SSL certificates

apache
# Redirect HTTP to HTTPS (must be a sibling block - vhosts cannot nest)
<VirtualHost *:80>
    ServerName example.com
    Redirect permanent / https://example.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName example.com
    DocumentRoot /var/www/example.com

    SSLEngine on
    SSLCertificateFile /path/to/cert.pem
    SSLCertificateKeyFile /path/to/key.pem
</VirtualHost>
๐Ÿ”’ Always use HTTPS in production
๐Ÿ“œ Let's Encrypt for free SSL certificates
โšก Enable HTTP/2 for better performance
๐Ÿ” HSTS header enforces HTTPS

More Apache tasks

Back to the full Apache cheat sheet