Skip to content

Instantly share code, notes, and snippets.

@e0ne
Created July 21, 2012 17:15
Show Gist options
  • Save e0ne/3156463 to your computer and use it in GitHub Desktop.
Save e0ne/3156463 to your computer and use it in GitHub Desktop.
Simple proxy server on NodeJS
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