任何人都可以請解釋什麼路由器的選項在這段代碼中做的。我從博客中獲得了這些代碼。我試圖實現節點http代理。路由器在節點http代理
var http = require('http'),
httpProxy = require('http-proxy');
//
//Leave out the hostnameOnly field this time, or set it to false...
//
var options = {
router: {
'domainone.com/appone': '127.0.0.1:9000',
'domainone.com/apptwo': '127.0.0.1:9001',
'domaintwo.net/differentapp': '127.0.0.1:9002'
}
}
//
//...and then pass in your options like last time.
//
var proxyServer = httpProxy.createServer(options).listen(80);
//
// ...and a simple http server to show us our request back.
//
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);
代理表已被棄用,以支持[add-on](https://github.com/nodejitsu/node-http-proxy#proxytable-api)。 – robertklep