Stuff & Nonsense

Dynamic proxy server in Node.js

Recently I’ve been tinkering with an idea I call nodeploy, for which I needed a dynamic proxy server…. ie, one I could change the configuration of on the fly.  I looked at HaProxy and nginx, both of which offer very limited or overly complex functionality that kind of did what I needed, but not really… so I decided to write something myself.

It’s mostly based off this blog post, but I couldn’t get that to work for the version of node I had so I did some rewriting and added some quick tests and here we are:

NodeProxy

Add a route to redis like this:

redisClient.hset(routes,‘test.nodeploy.it,‘127.0.0.1:8001);

run the server, and it will route any requests for ‘test.nodeploy.it’ to the specified url.

The great thing about this, and the entire reason for writing it is you can add or remove routes at run time…. which will become an important foundation of the nodeploy system.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.