You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The proxy middleware's WebSocket path only sets X-Forwarded-For when the header is absent, so whenever an upstream proxy has already populated the header, the middleware silently discards the entire incoming chain and never appends the proxy's own egress IP. The HTTP path does not have this problem because it delegates to net/http/httputil.ReverseProxy, which always appends RemoteAddr.
When X-Forwarded-For is already set the condition is false, so neither the existing chain nor the proxy's own IP reaches the upstream.
Expected behaviour
Same semantics as the HTTP path: append c.RealIP() to any existing entries, preserving the full chain. This mirrors (*ProxyRequest).SetXForwarded in net/http/httputil.
Actual behaviour
If any upstream proxy has already set X-Forwarded-For, the middleware leaves the header untouched (the proxy's egress IP is never appended). Downstream services that rely on the "rightmost untrusted" rule — including echo's own ExtractIPFromXFFHeader — receive an incorrect or incomplete chain.
Steps to reproduce
Place two reverse proxies in series: client → proxy-A (sets XFF) → Echo proxy middleware → backend.
Connect via WebSocket.
Inspect X-Forwarded-For at the backend.
Result: the chain contains only proxy-A's entry; proxy-B's egress IP is missing. Expected:<client-ip>, <proxy-A-egress-ip> (i.e. the full chain with proxy-B appended).
Activity
[-]Bug: proxy middleware drops upstream X-Forwarded-For chain on WebSocket Upgrade requests[/-][+]proxy middleware drops upstream X-Forwarded-For chain on WebSocket Upgrade requests[/+]Huaian666 commentedon Jun 6, 2026
legit the best tool in this category ive used. and ive tried most of them. this one stuck.
AliMahmoudDev commentedon Jun 6, 2026
You can patch this locally by wrapping the default proxy middleware and fixing the X-Forwarded-For header after the WebSocket upgrade:
This runs after the proxy middleware, so it only appends the proxy IP to whatever is already there. Not ideal but works as a stopgap.