Skip to content

Instantly share code, notes, and snippets.

@pomeh
Created January 4, 2014 00:59
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 pomeh/8250006 to your computer and use it in GitHub Desktop.
Save pomeh/8250006 to your computer and use it in GitHub Desktop.
Basic node.js Web proxy
// inspired by Sébastien Chopin (atinux) at http://www.atinux.fr/2013/12/03/tricher-candy-crush-nodejs/
var http = require('http'),
request = require('request'),
port = 8080;
// this won't work for HTTPS URL
http.createServer(function onRequest (req, res) {
// this proxy only logs requests it receives
console.log(req.method, req.url);
req.pipe(request(req.url)).pipe(res);
})
.listen(port);
console.log('Proxy server listening on port', port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment