Repository navigation
feat(proxy): send PROXY protocol v2 on TCP routes that ask for it - #238
Conversation
A TCP route forwards bytes, so the backend sees the proxy as the peer of every client. Behind TLS passthrough that defeats any per-address limit, and there is no header to carry the address. The route field proxyProtocol: 2 makes the managed proxy write a PROXY protocol v2 header before each connection. Discovery defines one TCP servers transport, onebox-proxy-protocol-v2, with proxyProtocol.version 2, and the route's service selects it through the serverstransport label. That is the form Traefik documents for v3.7; the per-service loadBalancer.proxyProtocol option is deprecated since v3.5.2 and is not generated. The transport is a service setting, so containers that disagree on it cannot share a service. During a rolling deploy that changes it, the newest healthy container decides and only agreeing servers stay in the service, so old containers leave rotation instead of receiving a header they do not expect. The field accepts only 2, only on protocol tcp, and only with a managed proxy, which is what defines the transport it names. The transport name is reserved in proxy.config dynamic files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Render a release with a TCP passthrough route that sets proxyProtocol: 2, build discovery's document from the web service's labels, and load it into the managed proxy's default Traefik image with the file provider. A busybox backend records its first bytes, which must be a PROXY v2 TCPv4 header. Without the serverstransport label the backend sees the client's TLS ClientHello instead, so the test fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Added an e2e case in 7f1e171:
🤖 Generated with Claude Code |
What this changes
Adds a TCP route field,
proxyProtocol: 2. With it, the managed proxy writes a PROXY protocol v2 header naming the client at the start of each connection. Without it, a TCP route (including TLS passthrough) shows the backend the proxy as the peer of every client, so per-address limits are shared by all clients and nothing carries the real address. The first user is a TLS-passthrough mTLS device endpoint whose server now reads PROXY v2 from a trusted proxy.internal/app):Route.ProxyProtocol(proxy_protocol, authored asproxyProtocol). The loader accepts only2, only onprotocol: tcp(an HTTP route already forwardsX-Forwarded-For) and only with a Onebox-managed proxy. That last rule exists because the managed proxy is what defines the transport the route names. The schema enforces the enum and the tcp requirement. The managed-proxy rule is cross-block, so it is listed inbeyondJSONSchema.traefik.tcp.services.<svc>.loadbalancer.serverstransport=onebox-proxy-protocol-v2, whichob previewshows. The deprecatedloadbalancer.proxyprotocol.versionis not generated.internal/discovery): when a TCP service selects that transport, the generatedonebox.ymldefinestcp.serversTransports.onebox-proxy-protocol-v2.proxyProtocol.version: 2and setsserversTransporton the service. Traefik documents this form for v3.7 (the pinnedtraefik:v3.7), and per-serviceloadBalancer.proxyProtocolhas been deprecated since v3.5.2. Any other transport value is refused, as an unknown scheme already is.internal/proxy): the transport name is reserved inproxy.configdynamic files, asonebox-compressalready is.No issue filed. This is the smallest change that lets a Onebox-deployed TCP backend see client addresses. There is no changelog file, so release notes come from the commit.
Why this is correct
internal/discovery: tests cover the transport being defined and selected, with the YAML Traefik reads asserted literally. They also cover no transport when the field is unset, enable and disable mid-roll (only agreeing, healthy servers remain, and the transport is defined only when selected), and refusal of an unknown transport label.internal/app: the generated runtime carries the label only on the route that sets it, and never the deprecated label. The canonical form keeps the field. Refusals for an HTTP route, version 1 andproxy.managed: falsereportroutes[0].proxyProtocol. There are four new conformance cases with frozen verdicts, and every existing verdict digest is unchanged, because the field isomitemptyand leaves existing projects byte-identical.internal/proxy: a dynamic extension that redefinestcp.serversTransports.onebox-proxy-protocol-v2is refused.proxyProtocol.version, v1 and v2 supported) and TCP services (loadBalancer.serversTransport). I did not run it against a live Traefik.Effect on the safety envelope
Existing projects are unaffected: without the field, the labels, the discovery output and the workload revisions do not change. A project that sets it changes what the managed proxy sends to that backend, and only that backend. The new discovery output needs the matching
onebox-discoveryimage, which is pinned to the runner release. No capability moves between "schema accepts" and "binary does", so/docs/reference/capabilitiesis unchanged.Checklist
just checkpasses locally (andjust ci: lint, govulncheck, actionlint, env-namespace).just checkverifies this).Not run:
just e2e(Docker suite), or a real deploy against Traefik v3.7. The first real deploy should confirm that the backend receives a v2 header and thatopenssl s_clientstill reaches the passthrough backend.🤖 Generated with Claude Code