nginx: Keep TLS 1.2, ECDSA and RSA, HSTS with subdomains
We ran this exact config. Tested on nginx 1.31 with OpenSSL 4.1, on 3 Dec 2026, with test certificates.
Needs nginx 1.25.1 or later, built with OpenSSL 3.5 or later for the post-quantum group. The TLS lines go in the http block. Swap example.com and the paths for your own.
# Don't put the nginx version in headers or error pages.
server_tokens off;
# TLS settings sit here, outside any server block, so every server gets them.
# nginx picks the key exchange group before it knows which hostname was asked
# for, so a group list inside one server block can be silently ignored.
# TLS 1.3, and TLS 1.2 with a short list of safe cipher suites.
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;
ssl_prefer_server_ciphers off;
# Hybrid post-quantum key exchange first. No P-256.
ssl_ecdh_curve X25519MLKEM768:X25519:secp384r1;
# No session tickets and no 0-RTT.
ssl_session_tickets off;
ssl_early_data off;
# Plain HTTP: redirect to HTTPS on the same hostname.
server {
listen 80;
listen [::]:80;
server_name example.com;
return 301 https://$host$request_uri;
}
# Any other hostname that reaches this server: refuse the handshake, so a
# scanner that connects by IP address doesn't get your certificate.
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl_reject_handshake on;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name example.com;
# nginx sends the ECDSA certificate to every client that can use it,
# and the RSA one to the rest.
ssl_certificate /etc/ssl/example.com/ecdsa/fullchain.pem;
ssl_certificate_key /etc/ssl/example.com/ecdsa/privkey.pem;
ssl_certificate /etc/ssl/example.com/rsa/fullchain.pem;
ssl_certificate_key /etc/ssl/example.com/rsa/privkey.pem;
# "always" sends these on error pages too. A location block with its own
# add_header drops all of these, so repeat them there.
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
root /var/www/example.com;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
What it does
- Accepts TLS 1.3 and TLS 1.2. On TLS 1.2 it allows only suites with forward secrecy and modern encryption. A TLS 1.2 connection gets no post-quantum protection. See protocol versions and cipher suites.
- Offers the hybrid post-quantum group first, then X25519 and P-384. P-256 is not offered. See post-quantum key exchange.
- Expects two certificates: ECDSA P-384, and RSA 3072 for clients that can't use ECDSA. See certificate strength.
- Sends HSTS for this hostname and every subdomain. Be sure all of them serve HTTPS first. See HSTS.
- Turns session tickets and 0-RTT off. See 0-RTT and session tickets.
What it leaves out
- OCSP stapling. See revocation.
- A Content-Security-Policy. It depends on what your pages load.
- HTTP/3. We haven't tested it.
Check what you deployed
openssl s_client -connect example.com:443 -groups X25519MLKEM768 -brief </dev/null
weeb probe example.com --fix
The first should print Negotiated TLS1.3 group: X25519MLKEM768. The second (get weeb) should show TLS 1.0 and 1.1 as unavailable, and TLS 1.2 as offered.