-
Notifications
You must be signed in to change notification settings - Fork 189
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
reverse proxy: use Rewrite instead of Director #324
base: sig-auth-acceptance
Are you sure you want to change the base?
Conversation
This is to mitigate Golang's behavior with `ReverseProxy.Director` when, after the outgoing request is mutated, any headers specified by "Connection" would get rmoved from the mutated request. `ReverseProxy.Rewrite()` is only called once the headers specified in "Connection" were already removed from the outgoing-to-be request.
target := cfg.KubeRBACProxyInfo.UpstreamURL | ||
pr.SetURL(target) | ||
pr.Out.Host = target.Host | ||
copyHeaderIfSet(pr.In, pr.Out, "X-Forwarded-For") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make sense to add the IP address of the client, if not already set?
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For#syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pr.SetXForwarded()
does that but only if X-Forwarded-For
is already set
Rewrite: func(pr *httputil.ProxyRequest) { | ||
target := cfg.KubeRBACProxyInfo.UpstreamURL | ||
pr.SetURL(target) | ||
pr.Out.Host = target.Host |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you set it, after rewrite removed it? To keep the same behavior as with the Director?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I meant to keep the behavior the same.
This is to mitigate Golang's behavior with
ReverseProxy.Director
when, after the outgoing request is mutated, any headers specified by "Connection" would get rmoved from the mutated request.ReverseProxy.Rewrite()
is only called once the headers specified in "Connection" were already removed from the outgoing-to-be request.Fixes #319
edit: useful resources for more context: