Created
November 2, 2012 20:20
-
-
Save adparadise/4004089 to your computer and use it in GitHub Desktop.
Basic Node Proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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