Set up SSL/TLS in Apache

A good Apache HTTPS configuration has three parts: the certificate with a complete chain, secure protocol and cipher settings, and the redirect from HTTP. Here are all three.

Enable modules

# Debian, Ubuntu
sudo a2enmod ssl headers http2 rewrite
# RHEL, Rocky, Alma
sudo dnf install mod_ssl

The vhost on port 443

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

    SSLEngine on
    SSLCertificateFile    /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem

    Protocols h2 http/1.1
    Header always set Strict-Transport-Security "max-age=63072000"
</VirtualHost>

Protocols and ciphers (global)

These settings are best applied to all vhosts, e.g. in /etc/apache2/mods-available/ssl.conf or /etc/httpd/conf.d/ssl.conf. They follow Mozilla’s “intermediate” recommendation:

SSLProtocol         -all +TLSv1.2 +TLSv1.3
SSLCipherSuite      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
SSLHonorCipherOrder off
SSLSessionTickets   off

OpenSSL picks the TLS 1.3 ciphers itself; the line only affects TLS 1.2. If you need the settings for a specific Apache and OpenSSL version, use the TLS config generator.

OCSP stapling (SSLUseStapling on) is only worth it with CAs that still offer OCSP. Let's Encrypt shut down OCSP in 2025, so it does not apply there.

Redirect HTTP to HTTPS

<VirtualHost *:80>
    ServerName  www.example.com
    ServerAlias example.com
    Redirect permanent / https://www.example.com/
</VirtualHost>

If you use certbot with HTTP validation, the port 80 vhost stays. certbot puts its challenge files under /.well-known/acme-challenge/; the redirect does not interfere.

Check and reload

sudo apachectl configtest
sudo systemctl reload apache2      # RHEL: httpd

Then check chain, protocols and expiry in the SSL check and the headers with the security headers check. More headers such as CSP are in the article security headers for nginx and Apache.

FAQ

Do I still need to offer TLS 1.0 and 1.1?

No. All browsers switched them off in 2020. Only very old devices or software still need them; better give those a separate vhost.

Where do I put the intermediate certificate?

Together with the server certificate in SSLCertificateFile, your own first, then the intermediates. With Let's Encrypt that is fullchain.pem.

How do I enable HTTP/2?

With Protocols h2 http/1.1; MPM event is required. Details in the article HTTP/2 and HTTP/3 with Apache.

Sources and documentation