Skip to content

Instantly share code, notes, and snippets.

@yltsrc
Created October 22, 2015 12:44
Show Gist options
  • Save yltsrc/01a11be3d9063d55ae1e to your computer and use it in GitHub Desktop.
Save yltsrc/01a11be3d9063d55ae1e to your computer and use it in GitHub Desktop.
var http = require('http');
var https = require('https');
var fs = require("fs")
var options = {
key: fs.readFileSync("ssl.key"),
cert: fs.readFileSync("ssl.crt")
}
https.createServer(options, onRequest).listen(8443);
function onRequest(client_req, client_res) {
console.log('serve: ' + client_req.url);
var opts = {
hostname: 'localhost',
port: 9393,
path: client_req.url,
method: 'GET'
};
var proxy = http.request(opts, function (res) {
res.pipe(client_res, {
end: true
});
});
client_req.pipe(proxy, {
end: true
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment