1 var httpProxy = require('../../lib/node-http-proxy');
3 // A simple round-robin load balancing strategy.
5 // First, list the servers you want to use in your rotation.
18 httpProxy.createServer(function (req, res, proxy) {
20 // On each request, get the first location from the list...
22 var target = addresses.shift();
25 // ...then proxy to the server whose 'turn' it is...
27 console.log('balancing request to: ', target);
28 proxy.proxyRequest(req, res, target);
31 // ...and then the server you just used becomes the last item in the list.
33 addresses.push(target);
36 // Rinse; repeat; enjoy.