I'm trying to configure HTTPS for my Express server. I found the following code from this question's answers.
console.log("Test 1");
var httpServer = http.createServer(app);
console.log("Test 2");
var httpsServer = https.createServer(credentials, app);
console.log("Test 3");
httpServer.listen(8080);
console.log("Test 4");
httpsServer.listen(8443);
console.log("Test 5");
Problem is the only thing that appears in the console is Test 1
and Test 2
. Nothing after that line seems to be running. I basically just want the same Express app to run on both HTTP and HTTPS.
In the past I just used server = app.listen(port);
to start the Express server.
Any ideas?
EDIT
The Node app continues to run with no errors but just doesn't print those final console.log
statements.
var fs = require('fs');
var privateKey = fs.readFileSync('ssl/servertest.key', 'utf8');
var certificate = fs.readFileSync('ssl/servertest.crt', 'utf8');
var credentials = {key: privateKey, cert: certificate};
servertest.key and servertest.crt.
Note: I know putting those online and making them public is a bad idea. Just using it for example. Before going into production I'm going to regenerate the SSL keys.