Skip to content

Instantly share code, notes, and snippets.

@alukinykh
Created February 11, 2017 11:01
Show Gist options
  • Save alukinykh/791f9c349841304dc9bc2a1749e6e620 to your computer and use it in GitHub Desktop.
Save alukinykh/791f9c349841304dc9bc2a1749e6e620 to your computer and use it in GitHub Desktop.
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