Go: x/net/proxy: Non-SOCKS ALL_PROXY results in proxy: unknown scheme: http

Created on 16 Aug 2016  路  3Comments  路  Source: golang/go

If the ALL_PROXY environment variable is set to a non-SOCKS address it results in the proxy: unknown scheme: http when it instead should ignore it.

  1. What version of Go are you using (go version)?
    go1.6.3 via docker
  2. What operating system and processor architecture are you using (go env)?
    windows/amd64
  3. What did you do?
    Have a http ALL_PROXY environment variable set and try to run Docker Toolbox, e.g. docker run hello-world
  4. What did you expect to see?
    Docker should work fine, Go should ignore non-SOCKS ALL_PROXY environment variable
  5. What did you see instead?
    Docker doesn't work because non-SOCKS ALL_PROXY environment variable is not ignored. The error can be traced back to https://github.com/golang/net/blob/master/proxy/proxy.go#L93.

Workaround: Run unset ALL_PROXY when you get error.

Most helpful comment

I can't believe this is still open.

All 3 comments

I'm not 100% sure, but are you sure setting ALL_PROXY to a http or https protocol makes sense? There might be traffic which is non-HTTP that wants to pass through the proxy.

I can't believe this is still open.

@nathanleclaire I think you have to register the Dialer Type yourself: https://godoc.org/golang.org/x/net/proxy#RegisterDialerType

Read more here and here:
http://blog.ralch.com/articles/network-programming-and-proxies-in-golang/
https://gist.github.com/jim3ma/3750675f141669ac4702bc9deaf31c6b

But I am also not sure and in the process of trying to setup a proxy for TCP dialers. HTTP client modifications are crazy easy:
http.DefaultTransport = &http.Transport{Proxy: http.ProxyURL(proxyURL)}

But using net.Dial and net.DialTimeout is less straightforward with a non-SOCKS5 proxy scheme.

Was this page helpful?
0 / 5 - 0 ratings