envoy icon indicating copy to clipboard operation
envoy copied to clipboard

tcp_proxy: Propagate non-2xx response status on CONNECT to client when using internal listeners

Open KeertiNarayan opened this issue 8 months ago • 3 comments

tcp_proxy: Propagate non-2xx response status on CONNECT to client when using internal listeners

Description: This is the setup:

Client -> Egress HCM -> Entry cluster -> Internal Encap listener -> tcp_proxy(TunnelingConfig, HTTP2 CONNECT) -> Upstream

When the upstream returns 403 on the CONNECT stream, tcp_proxy treats this as a failure to establish the tunnel and resets the downstream connection. The Entry cluster sees cx_connect_fail and we return a 503 to the client.

If we try UPSTREAM_FILTER_STATE(envoy.tcp_proxy.propagate_response_headers) at the egress HCM access log, we find that the filter state is not propagated but propagate_response_headers: true on the encap listener's tcp_proxy does show the 403 which helps for access log visibility at the egress proxy.

It would be really helpful to propagate the 403 back to the egress HCM's client response.

KeertiNarayan avatar Mar 16 '26 16:03 KeertiNarayan

Hi! I'd like to work on this. I'll spend some time understanding the codebase and how the response status gets lost between the internal listener and the client. I'll share my findings before I start writing any code. Happy to take pointers from maintainers on where to look.

kkukadia avatar Mar 25 '26 00:03 kkukadia

@k1chik Sure, please feel free to pick it up :)

agrawroh avatar Mar 25 '26 06:03 agrawroh

PR opened https://github.com/envoyproxy/envoy/pull/44157

kkukadia avatar Mar 30 '26 19:03 kkukadia