TCP failover proxy
JavaScript Shell
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
examples
lib
test
.gitignore
.travis.yml
LICENSE
README.md
package.json

README.md

failover-proxy Build Status

TCP proxy with a dynamic fallback, designed for high availability systems.

When proxy receives an error from the receiving side (e.g. your backend servers), it redirects the traffic to the next server from the pool, assuring that data gets buffered in between requests.

Installation

npm install failover-proxy

Usage

API

var proxy = require('failover-proxy')({
  hosts: [
    {
      host: '127.0.0.1',
      port: 9001
    },
    {
      host: '127.0.0.1',
      port: 9002
    }
  ]
});

proxy.listen(9000);

proxy.on('cycle', function (badHost, newHost) {
  //
  // `cycle` event happens when proxy couldn't contact the backend host and
  // switched to the next server. You can put your own reporting logic in here.
  //
});

Binary

$ cat options.json
{
  "hosts": [
    {
      "host": "127.0.0.1",
      "port": 9001
    },
    {
      "host": "127.0.0.1",
      "port": 9002
    }
  ],
  "port": 9000
}
$ failover-proxy options.json
failover-proxy listening on 9000