-
Notifications
You must be signed in to change notification settings - Fork 324
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
Small bug with forwarder when path changes #57
Comments
Thanks for the detailed write-up. I remember I had some bugs because of the way |
So not use standard URI, but just construct it manually from pieces |
Sounds good! I'm sure you've seen it but this doc seems to have the rules for how Opaque is used to construct the URL: https://golang.org/pkg/net/url/#URL.String |
So, maybe the bug here is that you're setting the opaque to RequestURI, which includes the scheme also, so the scheme gets double-included by URL.String(). Not sure if that's the only bug, but it seems to be what's happening. |
I stumbled upon the same thing here and was also about to create a bug report. Looking at the behavior of the methods of the URL struct I would say setting Opaque when using the URL in HTTP request is a bug and shouldn't happen. Right now I simply set Opaque to an empty value in my ReqRewriter, because otherwise all requests fail. |
Was there a fix for this at all? |
Not an official one, I think it just needs a tiny bit of work to avoid setting |
I believe this might be closed or obsoleted by https://github.com/vulcand/oxy/pull/108/files |
Wanted to check the best way to fix this bug before starting a PR.
I'm using Forwarder as a hijacking reverse proxy which rewrites the destination URL (so, it doesn't just reverse proxy like normal to a new destination host, it changes the host and path).
I thought I could just do something like replace
req.URL
:...except, that attempting to use this always returns a 400 Bad Request:
I was able to trace the bug to this line:
oxy/forward/fwd.go
Line 252 in cf724ef
which does:
The bug: If you call
outReq.URL.String()
after that line you get:http:http://foo/
, which obviously will die.I've read the docs on how Opaque is used but don't quite understand what the best global fix is for this. I was able to work around it by just removing that line entirely — and now everything works, both normal reverse-proxying and hijacking the request URL. :)
But some path tests break (but they also set some Opaque things manually), so I'm not sure what the right fix is here.
The text was updated successfully, but these errors were encountered: