node-tunnel - HTTP/HTTPS Agents for tunneling proxies
Example
var tunnel = require('tunnel');
var tunnelingAgent = tunnel.httpsOverHttp({
proxy: {
host: 'localhost',
port: 3128
}
});
var req = https.request({
host: 'example.com',
port: 443,
agent: tunnelingAgent
});
Installation
$ npm install tunnel
Usages
HTTP over HTTP tunneling
var tunnelingAgent = tunnel.httpOverHttp({
maxSockets: poolSize,
proxy: {
host: proxyHost,
port: proxyPort,
localAddress: localAddress,
proxyAuth: 'user:password',
headers: {
'User-Agent': 'Node'
}
}
});
var req = http.request({
host: 'example.com',
port: 80,
agent: tunnelingAgent
});
HTTPS over HTTP tunneling
var tunnelingAgent = tunnel.httpsOverHttp({
maxSockets: poolSize,
ca: [ fs.readFileSync('origin-server-ca.pem')],
key: fs.readFileSync('origin-server-key.pem'),
cert: fs.readFileSync('origin-server-cert.pem'),
proxy: {
host: proxyHost,
port: proxyPort,
localAddress: localAddress,
proxyAuth: 'user:password',
headers: {
'User-Agent': 'Node'
},
}
});
var req = https.request({
host: 'example.com',
port: 443,
agent: tunnelingAgent
});
HTTP over HTTPS tunneling
var tunnelingAgent = tunnel.httpOverHttps({
maxSockets: poolSize,
proxy: {
host: proxyHost,
port: proxyPort,
localAddress: localAddress,
proxyAuth: 'user:password',
headers: {
'User-Agent': 'Node'
},
ca: [ fs.readFileSync('origin-server-ca.pem')],
servername: 'example.com',
key: fs.readFileSync('origin-server-key.pem'),
cert: fs.readFileSync('origin-server-cert.pem'),
}
});
var req = http.request({
host: 'example.com',
port: 80,
agent: tunnelingAgent
});
HTTPS over HTTPS tunneling
var tunnelingAgent = tunnel.httpsOverHttps({
maxSockets: poolSize,
ca: [ fs.readFileSync('origin-server-ca.pem')],
key: fs.readFileSync('origin-server-key.pem'),
cert: fs.readFileSync('origin-server-cert.pem'),
proxy: {
host: proxyHost,
port: proxyPort,
localAddress: localAddress,
proxyAuth: 'user:password',
headers: {
'User-Agent': 'Node'
}
ca: [ fs.readFileSync('origin-server-ca.pem')],
servername: 'example.com',
key: fs.readFileSync('origin-server-key.pem'),
cert: fs.readFileSync('origin-server-cert.pem'),
}
});
var req = https.request({
host: 'example.com',
port: 443,
agent: tunnelingAgent
});
CONTRIBUTORS
License
Licensed under the MIT license.