Home About Me

An Nginx SSL Configuration, Checked with SSL Labs

The SSL Labs assessment for the host is shown below:

SSL Labs rating

The SSL-related section of the Nginx configuration is compact. It enables HTTP/2 on port 443, uses Let's Encrypt certificate and key files, sets a session timeout and cache, prefers the server's cipher order, loads DH parameters, enables OCSP stapling and verification, and adds HSTS and X-Frame-Options headers.

    listen 443 ssl http2;

    ssl_certificate /etc/letsencrypt/live/alair.cn/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/alair.cn/privkey.pem;

    ssl_session_timeout 60m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:RC4-SHA:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!DSS:!PKS;

    ssl_prefer_server_ciphers on;
    ssl_session_cache builtin:1000 shared:SSL:10m;
    ssl_dhparam /etc/ssl/certs/dhparam.pem;
    ssl_stapling on;
    ssl_stapling_verify on;

    add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
    add_header X-Frame-Options "DENY";

dhparam.pem can be generated with:

openssl dhparam -out dhparam.pem 4096

This command can run for a long time. If that is not practical, the bit size can be changed to 2048.