Skip to content

Enable post-quantum TLS on Nginx

Make Nginx prefer the X25519MLKEM768 hybrid key exchange, with classical fallback for old clients.

Tested on nginx 1.28.3, OpenSSL 3.5.10 Lab run 2026-12-05 5 min Requires Nginx built against OpenSSL 3.5 or newer

The fix

Put the hybrid group in its own first tuple. The / tells OpenSSL to prefer it, even when a client first sends only a classical key share.

nginx.conf (server or http block)
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ecdh_curve "X25519MLKEM768 / X25519:prime256v1:secp384r1";

Then reload: nginx -t && nginx -s reload.

Shortcut: if your Nginx uses OpenSSL 3.5+ and you have no ssl_ecdh_curve line, you already prefer post-quantum. The OpenSSL default does the same thing. Delete an old ssl_ecdh_curve line instead of adding one.

Check your OpenSSL first

nginx -V 2>&1 | grep -o "OpenSSL [0-9.]*"

You need 3.5 or newer. Older OpenSSL does not know X25519MLKEM768, and nginx -t will fail on the line above.

Where your Nginx comes from OpenSSL Ready?
Official nginx Docker images (Debian and Alpine tags) 3.5.x Yes
Debian 13, Ubuntu 25.10 / 26.04, Alpine 3.22, Rocky/Alma/RHEL 9 and 10 (current updates) 3.5.x Yes
Debian 12, Ubuntu 24.04 LTS 3.0.x No: upgrade the OS, or run Nginx from the official Docker image
Alpine 3.21 3.3.x No: move to Alpine 3.22

Versions checked by installing each image's own openssl package on 2026-12-06.

What the three common configs actually do

Tested in Docker against five client offers, including the exact one browsers send. "Preferred" means the server asks for post-quantum even when the client led with a classical key share.

Config Post-quantum What browsers get
"X25519MLKEM768 / X25519:…" (this fix) Preferred X25519MLKEM768
No ssl_ecdh_curve (OpenSSL 3.5 default) Preferred X25519MLKEM768
X25519MLKEM768:X25519:… (no /) Supported, not preferred X25519MLKEM768
X25519:prime256v1:… (old hardening guides) Off X25519 (classical)

"Supported, not preferred" looks the same in a browser today, but a client that leads with a classical key share gets classical encryption. Preferring post-quantum closes that gap.

An old hardening line such as ssl_ecdh_curve X25519:prime256v1; is a common reason a server with OpenSSL 3.5 is still classical-only.

Verify

openssl s_client -connect example.com:443 -groups X25519MLKEM768 </dev/null 2>&1 | grep "Negotiated TLS1.3 group"
# Negotiated TLS1.3 group: X25519MLKEM768

Or rescan with PQ Scan: the Confidentiality axis should read PQ preferred.

Things that don't change

  • Your certificate stays the same (post-quantum certificates are not available for public websites yet).
  • Clients without post-quantum support still connect with X25519 or P-256.
  • If a CDN or load balancer terminates TLS in front of Nginx, visitors see the CDN's TLS, not this config. Fix it there too.

Ask your AI about this fix

Copy the recipe as Markdown, or open it in an assistant that can read the page.