Skip to content

Instantly share code, notes, and snippets.

@indexzero
Created February 9, 2012 21:44
Show Gist options
  • Select an option

  • Save indexzero/1783490 to your computer and use it in GitHub Desktop.

Select an option

Save indexzero/1783490 to your computer and use it in GitHub Desktop.
A simple outbound proxy server with node-http-proxy
var httpProxy = require('http-proxy');
var server = httpProxy.createServer(function (req, res, proxy) {
//
// Inspect the request
//
console.dir(req);
//
// Proxy to the Remote Location
//
proxy.proxyRequest(req, res, {
host: 'path-to-remote-api-endpoint.com',
port: 80
});
});
//
// Start the proxy server. You should connect to
// http://localhost:3000/
//
server.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment