Skip to content

HAProxy TLS passthrough vs termination: decision criteria and end-to-end mTLS implications

When to terminate TLS at HAProxy, when to pass it through, and what each choice costs you in observability, mTLS, performance, and operational blast radius.

You’re standing up HAProxy in front of an application that already speaks TLS, and someone on the call asks the question that always sounds simple and never is: do we terminate TLS at the load balancer or pass it straight through to the backend? The answer determines what you can observe, what you can route on, what you must rotate, and whether mTLS between client and application even remains possible. Picking wrong here is reversible — but only by re-architecting the proxy tier later, which is the kind of project nobody schedules until it stops being optional.

What’s happening

HAProxy has two TLS modes, and the difference between them is whether HAProxy holds the certificate’s private key.

TLS termination means HAProxy holds the cert, decrypts the connection, processes the cleartext request (routing, ACLs, logging, headers, rate-limiting), and either re-encrypts to the backend (server ... ssl) or sends cleartext over the internal network. HAProxy is, for the duration of the connection, the TLS endpoint as far as the client is concerned. This unlocks every L7 feature HAProxy has: path-based routing, header rewrites, request-level metrics, sticky cookies, body inspection, WAF integration, response compression.

TLS passthrough means HAProxy runs in TCP mode (mode tcp), inspects the TLS ClientHello to read the SNI value (via req.ssl_sni), routes to a backend based on that, and forwards the encrypted stream byte-for-byte. The backend holds the cert and terminates TLS. HAProxy never sees the application data. It can balance, fail over, rate-limit by source IP, and log the SNI — and that’s it.

Most production deployments are termination, because L7 features matter more than the constraints of passthrough. The decision points are where one mode is genuinely better than the other.

How to verify

The fastest sanity check: which side holds the cert?

# Termination — cert is on HAProxy
grep -r 'crt /etc/haproxy/certs' /etc/haproxy/

# Passthrough — config will use mode tcp and route on req.ssl_sni
grep -A 5 'mode tcp' /etc/haproxy/haproxy.cfg

Confirm passthrough actually passes the cert through (run from a client):

# Should return the backend's cert, NOT one served by HAProxy
echo | openssl s_client -connect lb.example.com:443 -servername app.example.com 2>/dev/null \
  | openssl x509 -noout -subject -issuer -dates

Confirm termination is doing what you think (cert presented should be HAProxy’s, not the backend’s):

echo | openssl s_client -connect lb.example.com:443 -servername app.example.com 2>/dev/null \
  | openssl x509 -noout -subject -issuer

For an mTLS deployment, check that client certs are reaching the application — either via X-SSL-Client-* headers (termination, HAProxy validates and forwards metadata) or end-to-end (passthrough, application validates directly):

# Termination + forwarded headers
curl -fsSL --cert client.pem --key client.key https://app.example.com/whoami
# expects header echoed: X-SSL-Client-CN=...

# Passthrough — application validates client cert
curl -fsSL --cert client.pem --key client.key https://app.example.com/whoami
# application logs should show TLS peer cert

The fix

The decision flows from four questions, in order:

  1. Does the client perform mTLS with a cert the application must validate end-to-end (regulatory or audit requirement)? If yes, you need passthrough or HAProxy with verify required + an out-of-band attestation to the backend. Pure termination + X-SSL-Client-* headers does not satisfy “end-to-end mTLS” audit framing because HAProxy could in principle inject headers without a real client cert. Either pass through, or accept the model that HAProxy is part of your trust boundary and document it.

  2. Do you need L7 features (path routing, body inspection, header rewrite, response compression, WAF)? If yes, terminate. Passthrough gives you SNI-based routing and TCP-level controls and that’s all. A “path-based router that doesn’t terminate TLS” is a contradiction in terms — by definition the path is encrypted until you decrypt it.

  3. Do the backend applications already do their own TLS, with certs you don’t manage centrally? If yes, passthrough is the path of least resistance — HAProxy doesn’t need a cert, you don’t need a cert rotation pipeline for the LB, and the backend keeps doing what it was already doing. Termination would require either re-issuing certs to HAProxy or accepting the operational mismatch.

  4. What’s the performance / hardware profile? Termination is more CPU-intensive — HAProxy does the full TLS handshake on every new connection, including ECDSA or RSA private-key operations. On modern x86 with AES-NI the handshake cost is real but manageable; ChaCha20-Poly1305 helps on mobile clients. Passthrough offloads all of that to the backend, which is sometimes worse (if you have many backends each doing their own TLS) and sometimes better (if you have a small number of well-tuned backends and a single high-traffic LB pool you don’t want to scale up).

The fourth axis people forget: certificate rotation blast radius. With termination, your cert lives on the LB; rotating it is one place, one operation, every domain on the LB. With passthrough, the cert lives on each backend; rotating it is N places. Centralization is usually the right answer — until your auditor insists the LB cannot hold the cert because the LB is in a different trust zone than the application. Then the math flips.

A reasonable default for B2B SaaS: terminate at HAProxy, re-encrypt to the backend with the LB acting as a TLS client (server ... ssl verify required ca-file ...), forward X-SSL-Client-CN and X-SSL-Client-Verify headers for app-layer audit, and rotate the LB cert via ACME + a Runtime API push. This buys L7 visibility, lets the backend trust the LB, and keeps cert management centralized. The exception is mTLS-required audit, where you switch the affected hostnames to passthrough and accept the loss of L7 features for those routes.

The mistake to avoid: terminating TLS and then sending cleartext over the internal network “because it’s a private VLAN.” Cleartext on a shared LAN is one mis-routed cable, one VLAN-hopping bug, or one curious junior engineer with a tap from being a leak. Re-encrypt unless the backend is genuinely on the same host (Unix-domain socket).


Whichever mode you pick, both nginx single-node and HAProxy single-node sit at the edge of your environment — running them on Stack Harbor’s cloud compute with patching, monitoring, and on-call wired in is the lower-risk path. If you’re inheriting a proxy tier and want a second pair of eyes on the TLS posture, scope an audit with us.