Last active
February 16, 2016 07:48
-
-
Save janbiasi/56636a3c5f2b9712e012 to your computer and use it in GitHub Desktop.
Zukunft. Namics. Snippets für das Node.js Clustermodul (Part 1)
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'); | |
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