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
...
trusted := caddyhttp.GetVar(req.Context(), caddyhttp.TrustedProxyVarKey).(bool)
clientIP, _, _ = strings.Cut(clientIP, "%")
ipAddr, err := netip.ParseAddr(clientIP)
if err == nil {
// Check if the client is a trusted proxy
for _, ipRange := range h.trustedProxies {
if ipRange.Contains(ipAddr) {
trusted = true
break
}
}
}
...
Note that SplitHostPorthere is able to split non-ip hosts, so it seems more appropriate to consider that the host address is not necessarily an IP address .This change would maintain the current behavior (meaning that it would not break something that is already working) while allowing for other host address types.
The text was updated successfully, but these errors were encountered:
JordiSubira
changed the title
reverseproxy: Avoid returning an error if clientIP is not an IP address
reverseproxy: Avoid returning an error if host address is not an IP address
Apr 24, 2025
I am using the reverseproxy module with a custom underlay network, more concretely a SCION network. The SCION underlay network doesn't use IP addresses as host addresses. More concretely, the retrieved
addrPort
value on https://github.com/caddyserver/caddy/blob/v2.9.0-beta.3/modules/caddyhttp/reverseproxy/reverseproxy.go#L687 will yield and address of the following format [isd-as,ipv4]:port or [isd-as,ipv6%zone]:port.An error is returned on https://github.com/caddyserver/caddy/blob/v2.9.0-beta.3/modules/caddyhttp/reverseproxy/reverseproxy.go#L740 after
netip.ParseAddr(clientIP)
, in turn, returns an error. I would suggest to ignore the trusted proxy check ifnetip.ParseAddr(clientIP)
returns an error, for example something similar to this:Note that
SplitHostPort
here is able to split non-ip hosts, so it seems more appropriate to consider that the host address is not necessarily an IP address .This change would maintain the current behavior (meaning that it would not break something that is already working) while allowing for other host address types.The text was updated successfully, but these errors were encountered: