Skip to content

Instantly share code, notes, and snippets.

@joshontheweb joshontheweb/lb
Created Aug 5, 2013

Embed
What would you like to do?
var httpProxy = require('http-proxy');
//
// Addresses to use in the round robin proxy
//
var addresses = [
{
host: '192.241.227.80',
port: 80
},
];
var i = 0;
var server = httpProxy.createServer(function (req, res, proxy) {
console.log('request received');
proxy.proxyRequest(req, res, addresses[i]);
i = (i + 1) % addresses.length;
});
server.on('upgrade', function(req, socket, head) {
console.log('upgrade request received');
});
server.listen(80);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.