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

net/http/httputil: the reverse proxy is bypassed when the proxied site redirects to itself using an absolute URL #14237

Closed
ghost opened this issue Feb 5, 2016 · 4 comments
Labels
FrozenDueToAge help wanted NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@ghost
Copy link

ghost commented Feb 5, 2016

ReverseProxy doesn't follow redirects by itself, so if the proxied site redirects to itself using an absolute URL in the Location header (e.g. Location: http://servername/path), the following requests bypass the proxy.

http://play.golang.org/p/DHoUpoPGnf

It would be useful if ReverseProxy had a callback field that allowed modifying the response (at least the headers).

Another use case is when you want to proxy a site that requires registration and do not want any cookies to leak from the proxied server to the client.

@bradfitz bradfitz added this to the Go1.7 milestone Feb 5, 2016
@rsc rsc modified the milestones: Go1.8, Go1.7 May 18, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 7, 2016
@rsc
Copy link
Contributor

rsc commented Oct 26, 2016

@bradfitz, what do we want to do here?

@rsc rsc added NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. and removed NeedsFix The path to resolution is known, but the work has not been done. labels Oct 26, 2016
@bradfitz
Copy link
Contributor

I'd be fine with a new optional func on httputil.ReverseProxy like:

      // ModifyResponse is an optional function that modifies the Response from the backend.
      // If it returns an error, the proxy returns with StatusBadGateway.
      ModifyResponse func(*http.Response) error

/cc @odeke-em (if you're interested)

@odeke-em
Copy link
Member

Sorry for the late reply, I hadn't seen this till now. Sounds like a plan, thanks for the ping @bradfitz!

@gopherbot
Copy link

CL https://golang.org/cl/32356 mentions this issue.

@golang golang locked and limited conversation to collaborators Nov 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

5 participants