Skip to content

Instantly share code, notes, and snippets.

@deoxxa
Created October 22, 2012 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deoxxa/3929449 to your computer and use it in GitHub Desktop.
Save deoxxa/3929449 to your computer and use it in GitHub Desktop.
i broked it :< :< :< :< :<
var http = require('http'),
httpProxy = require('http-proxy');
var proxy = new httpProxy.RoutingProxy();
http.createServer(function (req, res) {
console.log("got request for proxy");
process.nextTick(function() {
proxy.proxyRequest(req, res, {
host: 'localhost',
port: 9000,
});
});
}).listen(8001);
http.createServer(function (req, res) {
console.log("got request for server");
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('request successfully proxied: ' + req.url +'\n' + JSON.stringify(req.headers, true, 2));
res.end();
}).listen(9000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment