Post

Better SSL! Get an A+ rating on your server’s SSL security

Google started ranking sites with HTTPS higher, so it’s a must. My server, a Linode instance, is running Nginx and has basic HTTPS from Letsencrypt - it’s working great. But I only get a B rating at Qualys’ SSL Labs with the nearly out of the box configuration that I am using. Let’s make that better.

First we need to generate a strong Diffie-Hellman group like so:

1
2
cd /etc/ssl/certs
sudo openssl dhparam -out dhparam.pem 4096

Next modify your nginx config file with:

1
ssl_prefer_server_ciphers on; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'; ssl_dhparam /etc/ssl/certs/dhparam.pem; ssl_session_cache shared:SSL:32m; ssl_buffer_size 8k; ssl_session_timeout 15m; }

And make sure you have a 301 redirect to the https url.

For a Ruby on Rails site uncomment the line in config/environments/production.rb :

1
config.force_ssl = true

Restart nginx and unicorn/puma/thin and retest the site. Boom, A+ rating!

This post is licensed under CC BY 4.0 by the author.