Skip to content

Conversation

@rolandjitsu
Copy link

When running on k8s and using a proxy such as ingress-nginx, the printed host in logs is not the user's IP. This patch will read the X-Forwarded-For header and use that instead of the request r.RemoteAddr if it's set.

@rolandjitsu rolandjitsu force-pushed the master branch 7 times, most recently from 26f7162 to dc3c477 Compare January 15, 2026 06:10
@mostynb
Copy link
Collaborator

mostynb commented Jan 15, 2026

Hi, this looks like two different changes in one PR. Could you drop the container image changes from this PR and create a new PR for that?

@rolandjitsu
Copy link
Author

Hi, this looks like two different changes in one PR. Could you drop the container image changes from this PR and create a new PR for that?

Will do.

@rolandjitsu
Copy link
Author

Hi, this looks like two different changes in one PR. Could you drop the container image changes from this PR and create a new PR for that?

Moved the change to #882.

if xff := r.Header.Get("X-Forwarded-For"); xff != "" {
// XFF format: client, proxy1, proxy2
parts := strings.Split(xff, ",")
remoteAddr = strings.TrimSpace(parts[0])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is untrustworthy data, I wonder if we should log it differently?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants