Added SSL config

This commit is contained in:
benweet 2014-12-16 00:30:16 +00:00
parent ffba11fc84
commit 0b10cde501

View File

@ -1,4 +1,6 @@
var cluster = require('cluster');
var http = require('http');
var https = require('https');
var app = require('./app');
var count = require('os').cpus().length;
@ -13,9 +15,24 @@ if(!process.env.NO_CLUSTER && cluster.isMaster) {
});
}
else {
// Listen on port 3000
var server;
var port = process.env.PORT || 3000;
app.listen(port, null, function() {
if(port == 443) {
// Configure HTTPS on OpsWorks
var fs = require('fs');
var credentials = {
key: fs.readFileSync(__dirname + '/../shared/config/ssl.key', 'utf8'),
cert: fs.readFileSync(__dirname + '/../shared/config/ssl.crt', 'utf8'),
ca: fs.readFileSync(__dirname + '/../shared/config/ssl.ca', 'utf8').split('\n\n')
};
console.log(credentials.ca)
server = https.createServer(credentials, app);
}
else {
server = http.createServer(app);
}
server.listen(port, null, function() {
console.log('Server started: http://localhost:' + port);
});
}