You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
net/http: considering supporting CIDR notation in no_proxy env variable #16704
Feature request - It would be helpful if the net/http client supported CIDR notation in the no_proxy environment variable, or allowed another way to configure the net/http client to ignore the http_proxy for large networks (ie 10.0.0.0/8 etc).
I had no luck finding an official "spec" for the no_proxy environment variable, but I believe supporting this notation would cause no issues and would allow users of net/http to add proxy exclusions for large networks.
During my searching, I came across an old issue #2158 where the functionality was discussed but not really addressed (as far as the CIDR notation goes)
What version of Go are you using (go version)?
go version go1.6.3 linux/amd64
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
What did you do?
Tried to use CIDR notation in the no_proxy env variable to exclude net/http client from using web proxy specified in http_proxy env variable for private network 10.0.0.0/8
What did you expect to see?
Expected http client library to ignore http_proxy for addresses in the 10.0.0.0/8 network.
What did you see instead?
net/http client tried to use the http_proxy for get/post requests to addresses in 10.0.0.0/8 network.
Cheers, and thanks for golang!
Reacted by Eddie, Stefan Gangefors, Di Xu, Matt Dupre and Kishan B
@bradfitz afaics the entire use of NO_PROXY and proxy env vars is effectively convention, and afaics.. the issue with transport construction, is that as go based software becomes more popular its not even an option for the users to set that up themselves, their dependent on std lib behavior. ie. here's a recent debug session i had where curl and python respect it but a go based binary (etcdctl) does not. this makes quite a bit painful for users of go software, and i'm seeing it filed multiple times on software written in go (particularly docker/moby).
changed the title [-]CIDR notation in no_proxy env variable for net/http client[/-][+]net/http: considering supporting CIDR notation in no_proxy env variable[/+]on Jun 30, 2017
For this to move forward, sometime should try to first write a "spec" for it, documenting which other languages/libraries already implement said spec. (But if languages Foo and Bar both just use libcurl or whatever, say that.)
Looking at implementations across other languages and browsers, a full implementation of a no_proxy spec can get complicated quite quickly, and there are arguments about what is right and what is wrong.
I vote to keep it simple with domain, ip and CIDR exclusions. This is what python requests library does. My need for no_proxy in corporate and government environments is just excluding domains and private subnets (10.0.0.0/8 etc).
Ports, URL schemes, IP wildcards (10.*.3.*), and the special keywords like <local> I believe should be avoided.
Following simple rules:
Environment variable must be no_proxy or NO_PROXY
Should contain a comma-separated list of domains, ip addresses, or networks.
Parent domain will exclude parent and all sub domains (ie google.com would exclude google.com and code.google.com)
Domains in the following form: google.com, .google.com and *.google.com are all equivalent
If sub domain is provided, parent domain(s) is not matched (ie code.google.com would not exclude google.com)
IP addresses (ie 127.0.0.1, 192.168.1.1) (IPv6?)
Networks in CIDR notation (ie 192.168.0.0/16) (IPv6?)
Both localhost and 127.0.0.1 are excluded by default
@bradfitz Given your last comment in my change, should I just abandon this change and create a new one for x/net/http/proxy?
Looks like we could attempt to reuse bits from x/net/proxy or else we have two different ways to parse no_proxy. Although I believe we already have differences between the two. Just a thought.
Found this thread while investigating Packer issues (compiled in GoLang) in which it is implied a fix may go out in 1.11 due this month? Hope so.
At any rate let me +1 this as well. Proxy use in certain verticals is common, and in the age of automation we often find ourselves needing to hit IPs as DNS simply isn't available yet.
Activity
bradfitz commentedon Aug 15, 2016
I'd rather not extend the functionality of
ProxyFromEnvironment, especially when there's no spec for it.You can implement
net/http.Transport.Proxyyourself (https://golang.org/pkg/net/http/#Transport) for specific behavior.kapilt commentedon Jun 30, 2017
@bradfitz afaics the entire use of NO_PROXY and proxy env vars is effectively convention, and afaics.. the issue with transport construction, is that as go based software becomes more popular its not even an option for the users to set that up themselves, their dependent on std lib behavior. ie. here's a recent debug session i had where curl and python respect it but a go based binary (etcdctl) does not. this makes quite a bit painful for users of go software, and i'm seeing it filed multiple times on software written in go (particularly docker/moby).
curl works with it
as does python
as does ruby
but go based binaries don't
[-]CIDR notation in no_proxy env variable for net/http client[/-][+]net/http: considering supporting CIDR notation in no_proxy env variable[/+]bradfitz commentedon Jun 30, 2017
@kapilt, okay, I'll reopen, but I don't plan to work on this myself.
bradfitz commentedon Jun 30, 2017
For this to move forward, sometime should try to first write a "spec" for it, documenting which other languages/libraries already implement said spec. (But if languages Foo and Bar both just use libcurl or whatever, say that.)
forrejam commentedon Jul 2, 2017
Looking at implementations across other languages and browsers, a full implementation of a no_proxy spec can get complicated quite quickly, and there are arguments about what is right and what is wrong.
I vote to keep it simple with domain, ip and CIDR exclusions. This is what python requests library does. My need for no_proxy in corporate and government environments is just excluding domains and private subnets (
10.0.0.0/8etc).Ports, URL schemes, IP wildcards
(10.*.3.*), and the special keywords like<local>I believe should be avoided.Following simple rules:
no_proxyorNO_PROXYgoogle.comwould excludegoogle.comandcode.google.com)google.com,.google.comand*.google.comare all equivalentcode.google.comwould not excludegoogle.com)127.0.0.1, 192.168.1.1) (IPv6?)192.168.0.0/16) (IPv6?)localhostand127.0.0.1are excluded by defaultReferences
python requests library (very simple - domain, ip, CIDR check)
https://github.com/requests/requests/blob/master/requests/utils.py#L629
https://github.com/requests/requests/blob/master/requests/utils.py#L583
Chromium (more complex - support for different schemes, ports and parts of domains)
https://cs.chromium.org/chromium/src/net/proxy/proxy_bypass_rules.h?l=142
https://cs.chromium.org/chromium/src/net/proxy/proxy_bypass_rules.h?l=153
https://cs.chromium.org/chromium/src/net/proxy/proxy_bypass_rules.cc?l=255
https://cs.chromium.org/chromium/src/net/proxy/proxy_config_service_linux_unittest.cc?q=no_proxy+package:%5Echromium$&l=1076
Some more reading
https://developer.mozilla.org/en-US/docs/No_Proxy_For_configuration
curl/curl#1208
https://www.gnu.org/software/wget/manual/html_node/Proxies.html
https://github.com/libproxy/libproxy/blob/master/libproxy/modules/ignore_domain.cpp
https://github.com/libproxy/libproxy/blob/master/libproxy/modules/ignore_hostname.cpp
https://github.com/libproxy/libproxy/blob/master/libproxy/modules/ignore_ip.cpp
gopherbot commentedon Jul 10, 2017
CL https://golang.org/cl/47853 mentions this issue.
15 remaining items
fraenkel commentedon May 9, 2018
@bradfitz Given your last comment in my change, should I just abandon this change and create a new one for x/net/http/proxy?
Looks like we could attempt to reuse bits from x/net/proxy or else we have two different ways to parse no_proxy. Although I believe we already have differences between the two. Just a thought.
gopherbot commentedon May 29, 2018
Change https://golang.org/cl/68091 mentions this issue:
net/http: vendor x/net/http/httpproxy, use it in net/httpnet/http: vendor x/net/http/httpproxy, use it in net/http
gopherbot commentedon May 30, 2018
Change https://golang.org/cl/115255 mentions this issue:
http/httpproxy: support CIDR notation and ports with NO_PROXYmatthewdupre commentedon Jun 8, 2018
I've hit this problem too - another +1 for an upstream fix. (We might work around it ourselves for now.)
Justin-DynamicD commentedon Jul 5, 2018
Found this thread while investigating Packer issues (compiled in GoLang) in which it is implied a fix may go out in 1.11 due this month? Hope so.
At any rate let me +1 this as well. Proxy use in certain verticals is common, and in the age of automation we often find ourselves needing to hit IPs as DNS simply isn't available yet.
forrejam commentedon Jul 6, 2018
From what I can see in https://go-review.googlesource.com/c/net/+/115255 it looks like it is progressing! :)
jansmets commentedon Jul 6, 2018
Someone please fix this. I wasted a lifetime figuring this out. Thank you :-)
bradfitz commentedon Jul 6, 2018
@jansmets, see https://golang.org/wiki/NoPlusOne
http/httpproxy: support CIDR notation and ports with NO_PROXY
gopherbot commentedon Jul 9, 2018
Change https://golang.org/cl/122655 mentions this issue:
vendor: update vendored x/net/http/httpproxygopherbot commentedon Jul 9, 2018
Change https://golang.org/cl/122619 mentions this issue:
http/httpproxy: update documentation for httpproxy