我正在尝试做这样的事情:
// Setup prox to handle blog requests
httpProxy.createServer({
hostnameOnly: true,
router: {
'http://localhost': '8080',
'http://localhost/blog': '2368'
}
}).listen(8000);
以前我用这个:
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
基本上,我仍然想使用 express ......但是,当人们去http://localhost/blog
博客但仍然被服务时port 8080
(最终将是端口 80)
所以我把它换成这个,效果更好。问题是快递接管了路由(据我所知)
var options = {
// pathnameOnly: true,
router: {
'localhost': 'localhost:8080',
'localhost/blog': 'localhost:2368'
}
}
// Setup prox to handle blog requests
var proxyServer = httpProxy.createServer(options);
proxyServer.listen(9000);
require('./app/server/router')(app);
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});