express-http-proxy
express-http-proxy copied to clipboard
respect http_proxy and no_proxy for corporate firewall env
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
.
@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.
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.
@monkpow bump. this PR is no longer waiting for feedback. i answered your inquiry more than a month ago. thanks!
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.
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
Looks like you could always pass an http-proxy-agent
object to reqOpts.agent
using the proxyReqOptDecorator
option.