-
-
Save jult/395ad9fd3e9773a54a67aaf689beab27 to your computer and use it in GitHub Desktop.
My nginx include for TLS A+ rating at ssllabs.com/ssltest using freenginx/1.31.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # version 2026 may 23 | |
| ssl_certificate /etc/letsencrypt/live/my.domain.net/fullchain.pem; | |
| ssl_certificate_key /etc/letsencrypt/live/my.domain.net/privkey.pem; | |
| ssl_trusted_certificate /etc/letsencrypt/live/my.domain.net/chain.pem; | |
| ssl_protocols TLSv1.2 TLSv1.3; | |
| ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; | |
| ssl_prefer_server_ciphers off; | |
| # Regenerate without -dsaparam: openssl dhparam -out /etc/ssl/dh4096.pem 4096 | |
| ssl_dhparam /etc/ssl/dh4096.pem; | |
| ssl_ecdh_curve secp384r1; | |
| ssl_session_cache shared:MozSSL:18m; | |
| ssl_session_timeout 1d; | |
| ssl_session_tickets off; | |
| resolver 1.1.1.1 1.0.0.1 [2606:4700:4700::1111] [2606:4700:4700::1001] valid=2h; | |
| resolver_timeout 9s; | |
| # OCSP stapling is phased out by LE.. | |
| #ssl_stapling on; | |
| #ssl_stapling_verify on; | |
| add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; | |
| # HTTP/3 — single consolidated Alt-Svc header | |
| add_header Alt-Svc 'h3=":443"; ma=86400'; |
Author
Author
don't use
add_header Content-Security-Policy "default-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' data:;" always;
it ruins all iframes and/or embedded remote media.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my include /etc/nginx/headers file contents;
See https://hstspreload.org/ for the stuff relating to HSTS preload.
Note that as soon as some nginx config (could be any snippet you use for a server) has a 'new' add_header entry, all previously set ones are gone. So, here's my pro tip:
Put an
include /etc/nginx/headers;
after every new header you've set, or at the bottom of your server/vhost conf file.
Then test if the headers are still sent using ssllabs, https://www.immuniweb.com/ssl/ and/or https://securityheaders.com/