Created
July 21, 2012 17:15
-
-
Save e0ne/3156463 to your computer and use it in GitHub Desktop.
Simple proxy server on NodeJS
This file contains 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') | |
http.createServer(function(request, response){ | |
var request_options = { | |
host: request.headers['host'], | |
port: 80, | |
path: request.url, | |
method: request.method | |
} | |
var proxy_request = http.request(request_options, function(proxy_response){ | |
proxy_response.pipe(response) | |
var responseCache = '' | |
proxy_response.on('data', function (chunk) { | |
}) | |
response.writeHead(proxy_response.statusCode, proxy_response.headers) | |
}) | |
request.pipe(proxy_request) | |
}).listen(8010) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment