home projects rice


Good SSL is important for any site. Over time I've combined bits of other configs, giving me this setup (which also gives a perfect ssltest score):

First generate /etc/ssl/certs/dhparam.pem:
sudo openssl dhparam -dsaparam -out /etc/ssl/certs/dhparam.pem 8192
Nginx config:

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    ssl_certificate /etc/letsencrypt/live/; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/; # managed by Certbot

    ssl_dhparam /etc/ssl/certs/dhparam.pem;
    ssl_protocols TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL;
    ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;

    ssl_session_tickets off; # Requires nginx >= 1.5.9
    ssl_stapling on; # Requires nginx >= 1.3.7
    ssl_stapling_verify on; # Requires nginx => 1.3.7
    resolver valid=300s;
    resolver_timeout 5s;
    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
    add_header X-Frame-Options DENY;
    add_header X-Content-Type-Options nosniff;
    gzip off;

    root /var/www/;

server {
    listen 80;

    location / {
        if ($scheme != "https"){
            return 301 https://$host$request_uri;
        return 404;

You'll need to comment out the 443 block before generating the first cert, otherwise nginx complains about the nonexistent cert files.

Get letsencrypt certs: sudo certbot --authenticator webroot --installer nginx -d -d -d --rsa-key-size 4096
Remove the 443 block comments, restart nginx and all should be great!