Skip to content

Instantly share code, notes, and snippets.

@tastywheat
Created November 13, 2013 20:21
Show Gist options
  • Save tastywheat/7455693 to your computer and use it in GitHub Desktop.
Save tastywheat/7455693 to your computer and use it in GitHub Desktop.
nodejs reverse proxy
var httpProxy = require('http-proxy');
var options = {
pathnameOnly: true,
// this list is processed from top to bottom, so '.*' will go to
// '127.0.0.1:3000' if the Host header hasn't previously matched
router : {
'/api': '127.0.0.1:4271',
//'': '127.0.0.1:3002',
//'^.*\.sample\.com': '127.0.0.1:3002',
'': '127.0.0.1:3000'
}
};
// bind to port 80 on the specified IP address
// Note: need to run this as root because port 80
httpProxy.createServer(options).listen(80);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment