Home

Have a project in mind?

Book a free scoping call

5.0 from 358 reviews · 600+ projects

How to Enable Post-Quantum TLS on NGINX (X25519MLKEM768)

Enable hybrid post-quantum key exchange on NGINX with OpenSSL 3.5: check your build, fix the ssl_ecdh_curve trap, log $ssl_curve, test with openssl s_client and roll back safely.

Muhammad NabeelMuhammad NabeelCo-founder, Teamseven
Published
Reading time
8 min read

“Co-founder and engineer at Teamseven. 9+ years building custom SaaS, CRMs, and AI products for clients in the US, UK, EU, and Australia.” Meet the author

Post-quantum TLS on NGINX with X25519MLKEM768

This is the setup we used to move teamseven.ltd to hybrid post-quantum TLS on our own NGINX server. It applies to any product that ends its HTTPS connections at NGINX, whether that is a whole site, an API gateway or a reverse proxy in front of a Node.js or .NET app. No application code changes.

The short version: NGINX built with OpenSSL 3.5 or later already offers X25519MLKEM768 by default. Most of the work is making sure your build is current, that an old config line isn't switching it off, and that you can see it working.

Step 1: Check which OpenSSL your NGINX uses

nginx -V 2>&1 | grep -i openssl

You want to see built with OpenSSL 3.5 or later. If it says 3.0 or 1.1.1, NGINX cannot offer ML-KEM at all, and any config that names X25519MLKEM768 will fail to load.

Ubuntu 24.04 and Debian 12 ship OpenSSL 3.0, so the stock NGINX packages on those releases cannot do it. Your options are a newer OS release that ships OpenSSL 3.5 (Debian 13 does), the official nginx.org packages built against a current OpenSSL, or a container image built on one. Check the output of nginx -V after any change; it is the only answer that counts.

Step 2: Look for the ssl_ecdh_curve trap

Search your config:

grep -rn "ssl_ecdh_curve" /etc/nginx/

If nothing comes back, NGINX uses OpenSSL's default list, which on 3.5 already starts with X25519MLKEM768. You may not need to change anything.

If you find a line like this, it is quietly switching post-quantum off:

ssl_ecdh_curve X25519:prime256v1:secp384r1;

That list was copied into a lot of configs from hardening guides years ago. It tells OpenSSL to offer only those classical groups, so browsers that would happily use the hybrid group never get the chance. Nothing is logged when this happens.

Either delete the line, or put the hybrid group first:

ssl_protocols  TLSv1.2 TLSv1.3;
ssl_ecdh_curve X25519MLKEM768:X25519:prime256v1:secp384r1;

Keep the classical groups after it. They are the fallback for clients that don't support ML-KEM yet. Never list X25519MLKEM768 on its own on a public server: every older client would be refused.

The hybrid group only works over TLS 1.3, so make sure TLS 1.3 is enabled. Keeping TLS 1.2 alongside it is fine for older clients.

Step 3: Log which group each connection negotiated

This is the step most guides skip, and it is the one that tells you whether the change worked. NGINX exposes the negotiated group in the $ssl_curve variable. Add it to a log format:

log_format tls_pq '$remote_addr [$time_local] "$request" $status '
                  '$ssl_protocol $ssl_curve "$http_user_agent"';

access_log /var/log/nginx/tls_pq.log tls_pq;

Connections using the hybrid exchange show X25519MLKEM768. Classical ones show X25519 or another curve. After a day you can count both:

awk '{print $(NF-1)}' /var/log/nginx/tls_pq.log | sort | uniq -c | sort -rn

The exact column depends on your format, so adjust the field if needed. What matters is the split: how much of your traffic is protected, and which user agents are falling back.

Step 4: Test and reload

Always test the config before reloading:

nginx -t && systemctl reload nginx

A reload keeps existing connections open, so there is no downtime. If nginx -t complains that it can't set the curves list, your NGINX is not built with OpenSSL 3.5 and you are back at step 1.

Step 5: Check it from outside

From a machine with OpenSSL 3.5 or later:

openssl s_client -connect your-domain.com:443 -groups X25519MLKEM768 </dev/null 2>/dev/null | grep -i "group"

You should see Negotiated TLS1.3 group: X25519MLKEM768. If the handshake fails, the server is not offering the hybrid group.

In Chrome, open DevTools, go to the Security tab and look at the connection details. The key exchange will read X25519MLKEM768.

Then test the fallback, because that is what protects your older clients:

openssl s_client -connect your-domain.com:443 -groups X25519 </dev/null 2>/dev/null | grep -i "group"

This should still connect and report X25519. If it fails, your config is refusing classical clients. Fix that before going further.

Step 6: Don't forget the hop behind NGINX

If NGINX proxies to another HTTPS service (proxy_pass https://...), that is a separate TLS connection where NGINX is the client. Whether it uses the hybrid group depends on the upstream server's support and NGINX's own OpenSSL build. If the upstream is on the same machine or a private network over plain HTTP, there is nothing to change on that hop, but record it in your cryptographic inventory so the decision is written down.

If you sit behind Cloudflare, it now uses the hybrid group to connect to origins that support it, so upgrading NGINX also protects the Cloudflare-to-origin hop. See post-quantum TLS on AWS and Cloudflare.

Rolling back

The change is one line, so the rollback is one line. Restore the previous ssl_ecdh_curve value (or the old package), run nginx -t, and reload. Keep the logging from step 3 either way; it costs nothing and you will want the numbers later.

Common problems

"SSL_CTX_set1_curves_list failed" on reload. NGINX is linked against OpenSSL older than 3.5. Upgrade the build.

Browsers still show X25519. An ssl_ecdh_curve line elsewhere in your config (often an included snippet) is overriding yours. Search every included file.

Some clients can't connect after the change. Your list probably no longer includes a classical group they support. Add X25519 and prime256v1 back after the hybrid group.

A firewall or proxy between you and some customers drops connections. The hybrid ClientHello is about a kilobyte larger. Some old middleboxes mishandle it. This shows up as failures from specific networks, not from everyone, and your logs will point to them.

When to get help

If you run one NGINX server in front of one app, this guide is most of the job. If you have several environments, a load balancer in front, internal services, mobile apps and partner integrations, the edge is the easy part. Our post-quantum migration work covers the whole chain, with a written report on what negotiates what, as part of our cloud and DevOps services.

FAQ

Do I need a new SSL certificate for post-quantum TLS? No. Hybrid key exchange works with your existing certificate. Certificates stay classical for now, because browsers don't yet support post-quantum ones.

Does X25519MLKEM768 work over TLS 1.2? No. The hybrid groups are defined for TLS 1.3 only. Clients connecting over TLS 1.2 use classical key exchange.

Will enabling post-quantum TLS slow NGINX down? The hybrid handshake carries about a kilobyte more data and slightly more computation per new connection. On a normal web server or API it is not noticeable, and it does not affect requests on an existing connection.

Which version of NGINX do I need? What matters is the OpenSSL version NGINX is built with, which must be 3.5 or later. The $ssl_curve variable used for logging has been in NGINX for several years.

TaggedNGINX post-quantumX25519MLKEM768OpenSSL 3.5post-quantum TLSssl_ecdh_curveDevOps

Start your project

Have a software project in mind? Tell us what you're building.

30 minutes. No slides. We'll look at your idea and tell you honestly whether we can help, and what it would actually take.

  • We usually reply within an hour
  • NDA available before we talk
  • 5.0 from 358 reviews · Fiverr Vetted Pro

What happens next

  1. 01
    Book a 30-minute slotPick a time that works. No prep needed.
  2. 02
    We have a real conversationYou explain what you're building. We ask the hard questions.
  3. 03
    You get a scoped proposalFixed price and fixed timeline within 48 hours, or we tell you why it's not a fit.