Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caddyhttp: Accept XFF header values with ports, when parsing client IP #6183

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

francislavoie
Copy link
Member

@francislavoie francislavoie commented Mar 21, 2024

Context: https://caddy.community/t/trusted-proxies-in-openshift/23205

As it turns out, some proxies like OpenShift (Red Hat Kubernetes platform) keep the port in the X-Forwarded-For header (or whatever configured client IP header). That's weird, but apparently not unheard of.

We weren't splitting up the value, so when we passed it to netip.ParseAddr it would fail, so the client_ip in logs didn't get populated. This fixes that, and add some clarifying comments in surrounding code.

@francislavoie francislavoie requested a review from mholt March 21, 2024 05:57
@francislavoie francislavoie added the bug 🐞 Something isn't working label Mar 21, 2024
@francislavoie francislavoie added this to the v2.8.0 milestone Mar 21, 2024
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, interesting. LGTM -- thank you Francis!

@mholt mholt merged commit 63d597c into master Mar 21, 2024
25 checks passed
@mholt mholt deleted the client-ip-with-port branch March 21, 2024 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants