Węzeł http-proxy i express
Próbuję zrobić coś takiego:
// Setup prox to handle blog requests
httpProxy.createServer({
hostnameOnly: true,
router: {
'http://localhost': '8080',
'http://localhost/blog': '2368'
}
}).listen(8000);
Wcześniej korzystałem z tego:
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
Zasadniczo chcę nadal używać ekspresu ... ale, kiedy ludzie się do niego wybierająhttp://localhost/blog
zabierz mnie na bloga, ale nadal będziesz obsługiwanyport 8080
(który ostatecznie będzie portem 80)
Więc przestawiłem to na to i działało lepiej. Problem polega na tym, że ekspres przejmuje routing (z tego, co mogę powiedzieć)
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'));
});