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: document that ProxyFromEnvironment also ignores loopback addresses #33695

Open
Matt3o12 opened this issue Aug 17, 2019 · 2 comments

Comments

@Matt3o12
Copy link

commented Aug 17, 2019

What version of Go are you using (go version)?

go version go1.11.12 linux/amd64 (but the code seems to indicate that this also happens on master).

This also seems to be affecting all platforms.

What did you do?

I set the local proxy to some address. The address does not really matter, because the client never connects to it (unexpected). http.Get to the loopback ip: 127.0.0.1 or [::1].

What did you expect to see?

Since the docs 1, 2 specifically mention that only requests who's req.URL.Host is localhost get ignored (not proxied), it is to be expected that the loopback would still work (e.g. 127.0.0.1 or [::1]). Instead, the code ensures that the Host is neither localhost nor any loopback ip.

What did you see instead?

The request never made it to the proxy, it went to the website directly. (I expected to see something along those lines: cannot connect to proxy example.org:12345) but got: Get http://127.0.0.1: dial tcp 127.0.0.1:80: connect: connection refused.


The documentation should be updated to point out that any loopback ip address will also get ignored. It would also be helpful to post the workaround mentioned here where it was discussed why localhost is ignored and how to "disable" that (using localhost.localdomain or localhost4, which is available on every linux machine works fine). That would have saved me quit a bit of time since the thread was hard to find.

It would probably be also worth discussing why this was implemented in the first place. If you don't want to use a proxy, there are several ways to do it (set Transport.Proxy = nil or set the environment variable noproxy). This makes debugging client requests harder then it needs to be (I find it easiest to use mitm-proxy to verify that all headers, etc are set correctly).

@bcmills bcmills changed the title Doc: ProxyFromEnvironment also ignores 127.0.0.1 + workaround net/http: document that ProxyFromEnvironment also ignores loopback addresses Aug 19, 2019

@bcmills bcmills added the NeedsFix label Aug 19, 2019

@bcmills bcmills added this to the Unplanned milestone Aug 19, 2019

@bcmills bcmills added the help wanted label Aug 19, 2019

@tomocy

This comment has been minimized.

Copy link
Contributor

commented Aug 21, 2019

I would like to handle it.

Sent with GitHawk

@gopherbot

This comment has been minimized.

Copy link

commented Aug 22, 2019

Change https://golang.org/cl/191306 mentions this issue: httpproxy: document all loopbacks are special cased not just localhost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.