Skip to content

Instantly share code, notes, and snippets.

@rendro
Last active August 29, 2015 14:19
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 rendro/7fa85aa0f6e043af6054 to your computer and use it in GitHub Desktop.
Save rendro/7fa85aa0f6e043af6054 to your computer and use it in GitHub Desktop.
Nano node http proxy
var http = require('http');
http.createServer(function requestHandler(clientRequest, clientRespose) {
clientRequest.pipe(http.request({
host: 'localhost',
port: 3003,
path: clientRequest.url,
method: clientRequest.method,
headers: clientRequest.headers
}, function(serverResponse) {
clientRespose.writeHead(serverResponse.statusCode, serverResponse.headers);
serverResponse.pipe(clientRespose);
}));
}).listen(process.env.PORT || 3000, function() {
console.log('Proxy server started on port ' + (process.env.PORT || 3000));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment