Is there a way to add/remove server entries dynamically to http-proxy ? #413

Closed
chiragsanghvi opened this Issue May 1, 2013 · 3 comments

Projects

None yet

4 participants

@chiragsanghvi

Used and played around with http-proxy,good for use.

We've a requirement in our project, where we need to scale/add node servers depending on load/traffic.Is there a way to add an entry to list of servers in http-proxy dynamically ?

@gisripa
gisripa commented Sep 20, 2013

@chiragsanghvi If you are talking about updating the routes dynamically after starting the proxy server, it can be achieved by adding routes as a json file. http-proxy listens to the file changes and updates the routes.

var options   = { router: 'routes.json' };

httpProxy.createServer(options).listen(80);

Contents of routes.json will be

"router": {
    "foo.com/baz": "127.0.0.1:8001",
    "foo.com/buz": "127.0.0.1:8002",
    "bar.com/buz": '127.0.0.1:8003'
  }
@fonini
fonini commented Jan 9, 2014

Actually, the contents of routes.json will be:

{ "router" : {
    "foo.com/baz" : "127.0.0.1:8001",
    "foo.com/buz" : "127.0.0.1:8002",
    "bar.com/buz" : '127.0.0.1:8003'
}}
@jcrugzz
Member
jcrugzz commented Jan 20, 2016

This is referencing an old version of http-proxy but if you come across this issue we have a new module that handles routing and this sounds like a feature that could be requested if needed. http-proxy-rules

@jcrugzz jcrugzz closed this Jan 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment