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

Add support for no_proxy / NO_PROXY #737

Open
jongolden opened this issue Jan 26, 2023 · 3 comments
Open

Add support for no_proxy / NO_PROXY #737

jongolden opened this issue Jan 26, 2023 · 3 comments

Comments

@jongolden
Copy link

I am currently blocked from using this package due to the lack of support for NO_PROXY.

Here is my scenario:

  • I am working behind a corporate proxy and have HTTP_PROXY set as proxy.company-subdomain.com:8080
  • I am required to download mongodb from an internal mirror at https://mirror.company-subdomain.com/mongodb-linux[...]
  • Internal URLs should not be called through the proxy, so I have NO_PROXY set to .company-subdomain,localhost
  • Calling internal URLs through the proxy will always result in a BAD_GATEWAY error

I'd like to see support for NO_PROXY in this package. It looks like it would involve updating MongoBinaryDownload#download such that it resolves the proxy similar to request's getProxyFromUri, which returns null if the URL is included in the NO_PROXY variable.

Let me know if you are willing to support this and I would be happy to open a pull request.

@hasezoey
Copy link
Collaborator

hasezoey commented Jan 26, 2023

for proxy we are currently using https-proxy-agent, which from what i can tell does not support setting any no-proxy settings, so that means we would either need to handle that our-self or switch to a different agent package - or completely switch to how we download things (like for example switching to request directly).
so this effectively means it is put off until at least a minor version.

workaround for now should be to unset the proxy variable you use for MMS, because the only access MMS does is in MongoBinaryDownload.download

Note: i have no experience in messing with proxies, so the workaround may not be fully correct and self-implementation would be too much for this single package


Edit:
i am open for suggestions for replacements for https-proxy-agent and something like request (which is deprecated), the requirements are:

  • no big dependencies
  • API that supports settings proxy and no-proxy
  • should work with https and http

@jongolden
Copy link
Author

jongolden commented Jan 27, 2023

I don't think https-proxy-agent needs to be replaced. It would be simple enough to replace

const proxy =
      process.env['yarn_https-proxy'] ||
      process.env.yarn_proxy ||
      process.env['npm_config_https-proxy'] ||
      process.env.npm_config_proxy ||
      process.env.https_proxy ||
      process.env.http_proxy ||
      process.env.HTTPS_PROXY ||
      process.env.HTTP_PROXY;

with something like

const proxy = getProxyFromUrl(downloadUrl);

Where getProxyFromUrl returns null if NO_PROXY is applicable to downloadUrl, otherwise returns the evaluation of the existing statement.

request's getProxyFromUri is just an example for how this might be implemented. Sorry for any confusion.

@hasezoey
Copy link
Collaborator

I don't think https-proxy-agent needs to be replaced. It would be simple enough to replace

i know that this could be done, but like i said it is kinda out-of-scope for this project to handle and should be handle-able by the library actually consuming the proxy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants