var options = {
router: {
'localhost/foo': 'localhost:8001',
'localhost/bar': 'localhost:8002',
'localhost/baz': 'localhost:8003'
}
};
var httpProxy = require('http-proxy').createServer(options);
httpProxy.listen(8000);
var foo = require('express').createServer();
var bar = require('express').createServer();
var baz = require('express').createServer();
foo.get('/*', function(req,res) {
res.send('foo\n');
});
bar.get('/*', function(req,res) {
res.send('bar\n');
});
baz.get('/*', function(req,res) {
res.send('baz\n');
});
foo.listen(8001);
bar.listen(8002);
baz.listen(8003);
$ curl localhost:8000/foo
foo
$ curl localhost:8000/bar
bar
$ curl localhost:8000/baz
baz