golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.73k stars 17.63k forks source link

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

Open bbodenmiller opened 8 years ago

bbodenmiller commented 8 years ago

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.

nathanleclaire commented 7 years ago

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.

brandond commented 5 years ago

I can't believe this is still open.

mdsauce commented 5 years ago

@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.

luochen1990 commented 1 year ago

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 think non-HTTP traffic pass through a http proxy is very normal