grpc / grpc-node

gRPC for Node.js
https://grpc.io
Apache License 2.0
4.47k stars 647 forks source link

Support wildcard domains in no_grpc_proxy/no_proxy proxy configurations. #1293

Open zamnuts opened 4 years ago

zamnuts commented 4 years ago

PR #1243 introduced proxy support, and preemptively both the no_grpc_proxy and no_proxy configurations which dictate what hosts/domains should not be proxied. Currently, only strict equality is used to test if a host should not be proxied. See https://github.com/grpc/grpc-node/blob/%40grpc/grpc-js%400.7.0/packages/grpc-js/src/http_proxy.ts#L119

This is great for applications that require mixed proxy usage (requests both internal and external). However, within an organization having an abundance of internal sub-domains (e.g. foo.example.com, bar.example.com, etc), every single known sub-domain must be included in the no_grpc_proxy/no_proxy list.

Solution

Support conventional wildcard entries within no_grpc_proxy/no_proxy. There are two ways to obtain multi-level sub-domain matching, whereby both have the same effect:

In both of these cases, foo.example.com, bar.qux.example.com, and example.com would match.

Secondarily, using no_proxy='*' effectively disables any and all proxy configurations. This is seen in request (linked below).

Additional references

request: https://github.com/request/request/pull/1096 curl: https://github.com/curl/curl/issues/1208#issuecomment-272837735 GNU Emacs: https://www.gnu.org/software/emacs/manual/html_node/url/Proxies.html

ebuildy commented 2 years ago

Code: https://github.com/grpc/grpc-node/blob/master/packages/grpc-js/src/http_proxy.ts#L152

Interesting implementation: https://github.com/request/request/blob/master/lib/getProxyFromURI.js#L19