你可以嘗試http-proxy
模塊,您可以指定代理作爲
var http = require('http'),
httpProxy = require('http-proxy');
//
// Create your proxy server and set the target in the options.
//
httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(8000); // See (†)
//
// Create your target server
//
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
res.end();
}).listen(9000);
他們可以在這裏https://github.com/nodejitsu/node-http-proxy
這是偉大的好的文檔,謝謝。這正是我正在尋找的。 – imns
你能舉出一個例子來回答這個問題嗎,這個問題包括由URI分隔的80端口上的2個獨立代理? – Sawtaytoes