Added SSL config
This commit is contained in:
parent
ffba11fc84
commit
0b10cde501
21
server.js
21
server.js
@ -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);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user