Created
July 16, 2012 19:00
-
-
Save fjakobs/3124364 to your computer and use it in GitHub Desktop.
SSL termination proxy
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 tls = require("tls"); | |
var net = require("net"); | |
var fs = require("fs"); | |
var host = "c9.dev"; | |
tls.createServer({ | |
key: fs.readFileSync(__dirname + "/key.pem"), | |
cert: fs.readFileSync(__dirname + "/cert.pem") | |
}, function(client) { | |
var socket = new net.Socket(); | |
socket.connect(80, host); | |
client.pipe(socket, { end: false }); | |
socket.pipe(client); | |
}).listen(443, host); | |
console.log("Listening at", host, 443); |
piscisaureus
commented
Jul 16, 2012
- You need error handling.
- Try to run this with node master and enjoy the performance bump :-)
How would I do proper error handling?
client.on('error', ...
socket.on('error', ...
right, but what to do with them? Log and ignore so that the app will at least not terminate?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment