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

respect http_proxy and no_proxy for corporate firewall env #286

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

btmurrell
Copy link

in your pre-1.x README, you had user instructions to set req agent to a configured http-proxy-agent. This PR makes that configuration automatic if the environment has HTTP_PROXY or http_proxy defined and ignores hosts listed in no_proxy.

@monkpow
Copy link
Collaborator

monkpow commented Dec 11, 2017

@btmurrell Hello, sorry for the long delay in responding. I think you are wanting the library to automatically use https for secure request, and allow you to list urls which will ignore the proxy instructions.

I'm reluctant to add an additional way to configure the proxy url, and the library already switches to https when given a signal; is there additional value to adding http-proxy-agent besides reading http_proxy off the env?

This is the reason the docs were dropped, btw. In a pre-1.0 version, the lib did not effectively support https, and so the additional agent configuration was required. Incremental upgrades have obviated the cases I'm aware of for using http-proxy-agent, but I'm happy to be corrected if I've got this wrong.

@btmurrell
Copy link
Author

thanks @monkpow . That's not exactly the behavior i am requesting. it's not about switching between http or https. it's about tunneling thru a proxy server if needed. You understand what a corporate firewall is right? It routes all network traffic through a proxy server to prevent direct access between machines on our internal network and the outside internet. For browsers, this is easily configured through a conventional proxy.pac file. For any app running from the command line, we specify "if this process needs to access public internet, route all traffic through the server specified by http_proxy env variable". For many developers at companies such as mine, it is a necessary painful existence.

If i write a node app and make requests using the npm request object, that request object knows how to read the http_proxy environment variable. the express-http-proxy module does not use the npm request object; instead, it uses the native nodejs http or https object. the only way to get out through a proxy is to add an agent property to the http|https object using the HttpsProxyAgent (that is what my PR implements, altho, admittedly, rather crudely). In fact, the npm request ultimately does the same with the abstracted tunnel-agent.

i am sure there is a reason why you are not using the npm request object -- i wonder what that might be. it seems to wrap all of this functionality tidily.

and, no_proxy is just a pattern of hosts for which we do not use the proxy. e.g. this would be hosts inside our corporate network rather than the internet.

hope this helps explain my request.

@btmurrell
Copy link
Author

btmurrell commented Jan 19, 2018

@monkpow bump. this PR is no longer waiting for feedback. i answered your inquiry more than a month ago. thanks!

 into feature/support-corporate-firewall

# Conflicts:
#	README.md
@notatestuser
Copy link

What exactly was the conclusion on this? I have a similar situation with needing to send my requests through an HTTP proxy server. @btmurrell @monkpow thanks.

@akshayeshenoi
Copy link

The lack of this feature is making it impossible to carry out development behind a corporate proxy. Prior to version 1.0.0, the solution to this problem was assigning the http-proxy-agent object to req.agent (#56 ).

This is not allowed in 1.0.0.

This line seems to provision a custom module, but there's no way I can configure that option.
Are you missing a line here?

@monkpow

@akshayeshenoi
Copy link

Looks like you could always pass an http-proxy-agent object to reqOpts.agent using the proxyReqOptDecorator option.

Example

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

Successfully merging this pull request may close these issues.

4 participants