Nginx SSL/TLS Configuration

Getting TLS right in Nginx requires choosing the correct ssl_protocols, cipher suites, and security headers. Our generator follows Mozilla's recommended profiles so your A+ rating is a copy-paste away.

Protocols and ciphers

Allow TLS 1.2 and 1.3 only, and let the client choose among modern AEAD ciphers.

ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;

HSTS, OCSP stapling and session settings

HSTS tells browsers to use HTTPS only. Only enable includeSubDomains or preload once every subdomain serves HTTPS. Stapling reduces handshake latency.

add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;

Open the TLS / SSL generator

Frequently asked questions

Is TLS 1.0 or 1.1 still needed?

No. Both are deprecated and disabled by all current browsers.

What does the "always" flag do on add_header?

Without it Nginx only adds the header on 2xx and 3xx responses, so error pages would go out without HSTS.

Guides