Created
February 11, 2017 11:01
-
-
Save alukinykh/791f9c349841304dc9bc2a1749e6e620 to your computer and use it in GitHub Desktop.
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
const http = require('http'); | |
http.createServer(onRequest).listen(3000); | |
function onRequest(req, cl_res) { | |
var options = { | |
hostname: req.headers.host, | |
port: 80, | |
path: req.url, | |
method: req.method | |
}; | |
if (req.headers.host === 'facebook.com' || req.headers.host === 'www.facebook.com') { | |
options.hostname = 'crystalnix.com'; | |
} | |
var proxy = http.request(options, function (res) { | |
console.log(res.headers); | |
res.pipe(cl_res); | |
}); | |
req.pipe(proxy); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment