Created
October 22, 2015 12:44
-
-
Save yltsrc/01a11be3d9063d55ae1e 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
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