Skip to content

Instantly share code, notes, and snippets.

@janbiasi
Last active February 16, 2016 07:48
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 janbiasi/56636a3c5f2b9712e012 to your computer and use it in GitHub Desktop.
Save janbiasi/56636a3c5f2b9712e012 to your computer and use it in GitHub Desktop.
Zukunft. Namics. Snippets für das Node.js Clustermodul (Part 1)
var http = require('http');
var httpProxy = require('http-proxy');
exports.createServer = function(host, proxyPort, httpPort) {
proxyPort = proxyPort || 8000;
httpPort = httpPort || 9000;
host = host || 'localhost';
// Erstellt den Proxy-Server
httpProxy.createServer(httpPort, host).listen(proxyPort);
// Erstellt den WebServer
http.createServer(function(req, res){
res.writeHead(200, { 'Content-Type':'text/plain' });
res.write('request successfully proxied!\n'
+ JSON.stringify(req.headers, true, 2));
res.end();
}).listen(httpPort);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment