Skip to content

Instantly share code, notes, and snippets.

@janl
Created June 6, 2013 09:45
Show Gist options
  • Save janl/5720448 to your computer and use it in GitHub Desktop.
Save janl/5720448 to your computer and use it in GitHub Desktop.
var proxy = require("http-proxy");
function proxy_couchdb(req, res, proxy) {
var random_port = Math.random() >= 0.5 ?
4444 : 5555;
console.log("Proxy to %d", random_port);
proxy.proxyRequest(req, res, {
host: '127.0.0.1',
port: random_port
});
}
proxy.createServer(proxy_couchdb).listen(3333);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment