Community Hub

SSL Configuration for Webserver

Posted by AliceTech Oct 2, 2023

I'm setting up a new Apache web server on Ubuntu 22.04 and need to configure SSL/TLS. I have a certificate from Let's Encrypt, but I'm not sure about the optimal settings for security and compatibility. Can anyone provide a sample ssl.conf snippet and explain the key directives?

Sample Configuration

<IfModule mod_ssl.c>
    SSLEngine on
    SSLCertificateFile      /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile   /etc/letsencrypt/live/example.com/privkey.pem

    # Preferred protocols
    SSLProtocol             all -SSLv3 -TLSv1 -TLSv1.1

    # Strong ciphers, order matters
    SSLCipherSuite          HIGH:!aNULL:!MD5:!3DES
    SSLHonorCipherOrder    on

    # OCSP Stapling
    SSLUseStapling          on
    SSLStaplingResponderTimeout 5
    SSLStaplingReturnResponderErrors off

    # HSTS (adjust max-age as needed)
    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"

    # MIME type enforcement
    AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript

    # Diffie-Hellman parameters (generate with: openssl dhparam -out dhparam.pem 2048)
    SSLOpenSSLConfCommand  DHParameters "/etc/ssl/certs/dhparam.pem"
</IfModule>

Explanation of Key Directives

After adding the config, test it with openssl s_client -connect yourdomain.com:443 -tls1_2 or use Qualys SSL Labs for a full analysis.

Comments (2)

BobOpsOct 3, 2023

Great snippet! I’d also add SSLCompression off to prevent BREACH attacks.

CharlieDevOct 4, 2023

If you’re on Apache 2.4.38+, you can replace the DHParameters line with SSLCurve to let OpenSSL pick the best curve automatically.