Simple HTTP(S) proxy tunnelling agents.
Node.js >= 4
is required. To install, type this at the command line:
npm install auto-tunnel
const http = require('http');
const tunnel = require('auto-tunnel');
http.get({
agent: tunnel('http://hostname/'),
host: 'hostname',
path: '/'
}, function(response) {
});
You can override the internal environmental variable (HTTP_PROXY
, etc) check with proxyUrl
:
tunnel('http://hostname/', {
proxyUrl: 'http://proxy/'
})
You can supply headers to the proxy with proxyHeaders
:
tunnel('http://hostname/', {
proxyHeaders: {
'user-agent': 'my app'
}
})