Skip to content

Instantly share code, notes, and snippets.

@No9
Last active January 19, 2018 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save No9/253e855d8cf70a580afbf6ff293e9446 to your computer and use it in GitHub Desktop.
Save No9/253e855d8cf70a580afbf6ff293e9446 to your computer and use it in GitHub Desktop.
strong tls
var https = require('https');
var cluster = require('cluster');
var express = require('express');
var fs = require('fs');
var shareTlsSessions = require('strong-cluster-tls-store');
if (cluster.isMaster) {
// Count the machine's CPUs
var cpuCount = require('os').cpus().length;
// Create a worker for each CPU
for (var i = 0; i < cpuCount; i += 1) {
cluster.fork();
}
} else {
var app = express();
// configure the app
app.get('/', function (req, res) {
res.send('Hello World!');
});
var httpsOpts = {
key : fs.readFileSync('key.pem'),
cert : fs.readFileSync('cert.pem'),
passphrase: '1290'
}
// Start the server and configure TLS sessions sharing
var server = https.createServer(httpsOpts, app);
shareTlsSessions(server);
server.listen(8080);
}
// openssl s_client -reconnect -port 8080 | grep -E 'New|Reused'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment