Skip to content

Instantly share code, notes, and snippets.

@adparadise
Created November 2, 2012 20:20
Show Gist options
  • Save adparadise/4004089 to your computer and use it in GitHub Desktop.
Save adparadise/4004089 to your computer and use it in GitHub Desktop.
Basic Node Proxy
var http = require('http');
var request = require('request');
var remoteHost = "cantina.co";
var localPort = 8090;
function server (httpRequest, httpResponse) {
var remoteRequest, remoteURL;
console.log("piping: " + httpRequest.url);
remoteURL = "http://" + remoteHost + httpRequest.url;
remoteRequest = request(remoteURL);
remoteRequest.pipe(httpResponse);
};
http.createServer(server).listen(localPort);
console.log("Ready for connections...");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment