私はこのようなことをしようとしています:
// 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'));
});
基本的に、私はまだエクスプレスを使いたいと思っています...しかし、人々が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'));
});