I was working in a corporate network behind a proxy server. In my code I can set the proxy by using the approach mentioned in this thread.
But the problem is that mo
Unfortunately, it seems that proxy information must be set on each call to http.request. Node does not include a mechanism for global proxy settings.
The global-tunnel-ng module on NPM appears to handle this, however:
var globalTunnel = require('global-tunnel-ng');
globalTunnel.initialize({
host: '10.0.0.10',
port: 8080,
proxyAuth: 'userId:password', // optional authentication
sockets: 50 // optional pool size for each http and https
});
After the global settings are establish with a call to initialize, both http.request and the request library will use the proxy information.
The module can also use the http_proxy environment variable:
process.env.http_proxy = 'http://proxy.example.com:3129';
globalTunnel.initialize();