Sha256: 3d6a9765592a39fbd452eb66b55d9b2847c43edb520c21fb5f8404b7c36aa4e2
Contents?: true
Size: 754 Bytes
Versions: 17
Compression:
Stored size: 754 Bytes
Contents
var httpProxy = require('../../lib/node-http-proxy'); // // A simple round-robin load balancing strategy. // // First, list the servers you want to use in your rotation. // var addresses = [ { host: 'ws1.0.0.0', port: 80 }, { host: 'ws2.0.0.0', port: 80 } ]; httpProxy.createServer(function (req, res, proxy) { // // On each request, get the first location from the list... // var target = addresses.shift(); // // ...then proxy to the server whose 'turn' it is... // console.log('balancing request to: ', target); proxy.proxyRequest(req, res, target); // // ...and then the server you just used becomes the last item in the list. // addresses.push(target); }).listen(8000); // Rinse; repeat; enjoy.
Version data entries
17 entries across 17 versions & 2 rubygems