daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest Mar 18th, 2013 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var http = require('http'),
  2.     httpProxy = require('http-proxy');
  3.  
  4. //
  5. // Create a new instance of HttProxy to use in your server
  6. //
  7. var proxy = new httpProxy.RoutingProxy();
  8.  
  9. //
  10. // Create a regular http server and proxy its handler
  11. //
  12. var proxyOptions = {
  13.   pathnameOnly: true,
  14.   router: {
  15.     '/app': 'localhost:9000',
  16.     '/accounts': 'localhost:9002'
  17.   }
  18. };
  19. var proxyServer = httpProxy.createServer(proxyOptions);
  20. proxyServer.listen(9001);
  21.  
  22. http.createServer(function (req, res) {
  23.   res.writeHead(200, { 'Content-Type': 'text/plain' });
  24.   res.write('request successfully proxied: ' + req.url +'\n' + JSON.stringify(req.headers, true, 2));
  25.   res.end();
  26. }).listen(9000);
  27.  
  28. http.createServer(function (req, res) {
  29.   res.writeHead(200, { 'Content-Type': 'text/plain' });
  30.   res.write('request successfully proxied: ' + req.url +'\n' + JSON.stringify(req.headers, true, 2));
  31.   res.end();
  32. }).listen(9002);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top