Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var http = require('http'),
- httpProxy = require('http-proxy');
- //
- // Create a new instance of HttProxy to use in your server
- //
- var proxy = new httpProxy.RoutingProxy();
- //
- // Create a regular http server and proxy its handler
- //
- var proxyOptions = {
- pathnameOnly: true,
- router: {
- '/app': 'localhost:9000',
- '/accounts': 'localhost:9002'
- }
- };
- var proxyServer = httpProxy.createServer(proxyOptions);
- proxyServer.listen(9001);
- http.createServer(function (req, res) {
- res.writeHead(200, { 'Content-Type': 'text/plain' });
- res.write('request successfully proxied: ' + req.url +'\n' + JSON.stringify(req.headers, true, 2));
- res.end();
- }).listen(9000);
- http.createServer(function (req, res) {
- res.writeHead(200, { 'Content-Type': 'text/plain' });
- res.write('request successfully proxied: ' + req.url +'\n' + JSON.stringify(req.headers, true, 2));
- res.end();
- }).listen(9002);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement