4

While trying out http-proxy with node.js, I have the following piece of code:

var httpProxy = require('http-proxy');

httpProxy.createServer(
  require('proxy-by-url')({
  '/AAA': { port: 80, host: 'myDomain.com' },
  '/BBB': { port: 80, host: 'myDomain.com' }
  })
).listen(8000);

Obviously all requests to http://localhost:8000/AAA and http://localhost:8000/BBB are proxied to http://myDomain.com

I'm trying to proxy the requests to http://localhost:8000/AAA to http://myDomain.com/AAA/rss.xml but cannot figure out how to set that up.

I tried with:

'/AAA': { port: 80, host: 'myDomain.com/AAA/rss.xml' }

but it is throwing exceptions.

'/AAA': { port: 80, host: 'myDomain.com', url: '/AAA/rss.xml' }

or

'/AAA': { port: 80, host: 'myDomain.com', path: '/AAA/rss.xml' }

are inefficiency.

Does someone has an idea on how to set that up?

E. Jaep
  • 2,095
  • 1
  • 30
  • 56
  • If you're worried about efficiency, perhaps look into haproxy. With its ACL, you can perform the path-based routing you want without worrying about performance. – Angelo R. Dec 30 '14 at 21:20

0 Answers0