TLS passthrough versus termination
Choose the TLS endpoint
In passthrough, the client negotiates directly with the backend through a byte-forwarding proxy. In termination, Nginx presents its own certificate, decrypts the connection, and forwards application bytes. With re-encryption, Nginx initiates a separate TLS connection to the backend. Each TLS leg has its own identity and handshake. A generic stream terminator still does not become an HTTP parser.
Passthrough: client ===== TLS ===== backendTermination: client == TLS == Nginx -- clear bytes -- backendRe-encryption: client == TLS == Nginx == separate TLS == backendTerminate TLS in stream
This alternative server fragment requires the stream SSL module and the matching library. The certificate and key paths resolve under the isolated lab prefix; generate disposable material before use. The cleartext destination must be a reviewed loopback-only application that understands the forwarded bytes. Port 19245 is illustrative and not used by the passthrough lab. For routing by HTTP path or adding HTTP headers, use the HTTP subsystem instead.
server { listen 127.0.0.1:19244 ssl; ssl_certificate certs/atlas.pem; ssl_certificate_key certs/atlas.key; ssl_protocols TLSv1.2 TLSv1.3; proxy_pass 127.0.0.1:19245;}Verify a separate upstream TLS leg
This replacement fragment belongs in the terminating server, not the passthrough listener. Turning on proxy_ssl creates a new TLS connection rather than forwarding the original handshake unchanged. For a fixed IP endpoint, explicitly name the expected certificate identity and enable SNI. Verification requires a trusted certificate file and proxy_ssl_verify on; do not disable it to hide a name or trust failure. The lab uses a self-signed atlas certificate as an explicit local trust anchor; real services should use a reviewed CA chain.
# Inside a terminating stream server, for a TLS backend:proxy_pass 127.0.0.1:19241;proxy_ssl on;proxy_ssl_name atlas.test;proxy_ssl_server_name on;proxy_ssl_verify on;proxy_ssl_trusted_certificate certs/atlas.pem;proxy_ssl_protocols TLSv1.2 TLSv1.3;Respect the PROXY protocol boundary
PROXY protocol conveys connection metadata in a preamble. A listener configured to receive it expects a trusted sender to provide that preamble before the application bytes. Outgoing proxy_protocol on requires a peer designed to receive it; an ordinary TLS endpoint expects a ClientHello instead. The two directions are independent. Do not expose a PROXY-enabled listener to untrusted clients or enable outgoing PROXY protocol against the lab Python TLS servers.
Trusted sender → [PROXY metadata][TLS ClientHello] → compatible receiverOrdinary TLS peer expects: [TLS ClientHello]Practice and next steps
For a fictional service requiring backend-owned keys and end-to-end client TLS, choose passthrough. For an HTTP service requiring path routing and a verified encrypted backend leg, choose HTTP termination plus verified upstream TLS. Explain the trust boundaries and why generic stream termination alone cannot match paths.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
TLS passthrough versus termination
Compare visibility and certificate ownership
Which pattern preserves backend-owned client TLS?
What does proxy_ssl on add?
Which settings verify a fixed upstream named atlas.test?
What must a backend support before outgoing PROXY protocol is enabled?
Which subsystem should route an HTTP request by decrypted path?