그에 대한 NPM 모듈이있다 :
https://www.npmjs.com/package/global-tunnel
var globalTunnel = require('global-tunnel');
globalTunnel.initialize({
host: '10.0.0.10',
port: 8080,
sockets: 50 // optional pool size for each http and https
});
가 아니면에만 프록시 특정 요청하려면 글로벌 터널의 원동력 인 터널 패키지를 (사용할 수 있습니다 위의) :
https://www.npmjs.com/package/tunnel
var tunnel = require('tunnel');
// create the agent
var tunnelingAgent = tunnel.httpsOverHttps({
proxy: {
host: 'localhost',
port: 3128
}
});
var req = https.request({
host: 'example.com',
port: 443,
// pass the agent in your request options
agent: tunnelingAgent
});
요 수 http.globalAgent를 사용하는 예제를 제공합니다. {host : 'http.proxy.somewhere.com', 포트 : 1234, 경로 : 'http://www.google.com'} '을 옵션 및 그 자신의 요청에 대한 작동하지만'http : // localhost.options = {host : 'http.proxy.somewhere.com', port : 1234};'내 회사 프록시는 http : // http .proxy.somewhere.com : 1234'이고 작동하지 않습니다. – jonnie
예, 모든 아웃 바운드 요청을 globalAgent가있는 프록시를 통해 라우팅하는 예를 제공해주십시오. –