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

feat(proxy): flag to keep forwarded headers #706

Merged
merged 6 commits into from
Jul 18, 2023
Merged

Conversation

aeneasr
Copy link
Member

@aeneasr aeneasr commented Jul 18, 2023

Adds a feature flag to revert regressions introduced by switching to proxy.Rewrite.

@aeneasr aeneasr changed the title feat(proxy): flag to keep forawrded headers feat(proxy): flag to keep forwarded headers Jul 18, 2023
c.setScheme(r)
c.setHost(r)

*r.Out = *r.Out.WithContext(context.WithValue(ctx, hostConfigKey, c))
Copy link
Member Author

Choose a reason for hiding this comment

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

This is already done by getHostConfig

if err != nil {
o.onReqError(r.Out, err)
return
}

if c.TrustForwardedHeaders {
headers := []string{
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes the regression

Comment on lines +20 to +21
ReqMiddleware func(req *httputil.ProxyRequest, config *HostConfig, body []byte) ([]byte, error)
HostMapper func(ctx context.Context, r *http.Request) (context.Context, *HostConfig, error)
Copy link
Member Author

Choose a reason for hiding this comment

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

It's no longer possible to use the context properly because we don't know whether we get the context from req.In or req.Out now. So context needs to be explicit now.

@aeneasr aeneasr merged commit e77f73f into master Jul 18, 2023
6 checks passed
@aeneasr aeneasr deleted the forwarded-headers branch July 18, 2023 10:13
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.

1 participant