我的代码
// 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端口)
所以我换了这个,效果更好了。问题是express接管了路由(据我所知)。
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'));
});
相似问题