Skip to content

Commit

Permalink
Added SSL config
Browse files Browse the repository at this point in the history
  • Loading branch information
benweet committed Dec 16, 2014
1 parent ffba11f commit 0b10cde
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
});
}
Expand Down

0 comments on commit 0b10cde

Please sign in to comment.