Http-proxy redirects to a specific path

Having tried http-proxy using node.js, I have the following code snippet:

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 proxied to http://myDomain.com

I am trying to proxy http://localhost:8000/AAA requests to http://myDomain.com/AAA/rss.xml but cannot figure out how to install this.

I tried:

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

but he throws exceptions.

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

or

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

are ineffective.

Does anyone have an idea on how to install this?

+4
source share

Source: https://habr.com/ru/post/1485887/


All Articles