add https support 2

This commit is contained in:
Manuel Araoz 2014-08-21 13:47:51 -04:00
parent e3de0efdd2
commit 506a267ed0
2 changed files with 6 additions and 4 deletions

View File

@ -91,6 +91,7 @@ INSIGHT_IGNORE_CACHE # True to ignore cache of spents in transaction, with more
ENABLE_MAILBOX # if "true" will enable mailbox plugin ENABLE_MAILBOX # if "true" will enable mailbox plugin
ENABLE_RATELIMITER # if "true" will enable the ratelimiter plugin ENABLE_RATELIMITER # if "true" will enable the ratelimiter plugin
LOGGER_LEVEL # defaults to 'info', can be 'debug','verbose','error', etc. LOGGER_LEVEL # defaults to 'info', can be 'debug','verbose','error', etc.
ENABLE_HTTPS # if "true" it will server using SSL/HTTPS
``` ```

View File

@ -64,14 +64,15 @@ var expressApp = express();
// setup http/https base server // setup http/https base server
var protocol = config.enableHTTPS ? https : http; var server;
var serverOpts = {};
if (config.enableHTTPS) { if (config.enableHTTPS) {
var serverOpts = {};
serverOpts.key = fs.readFileSync('./etc/test-key.pem'); serverOpts.key = fs.readFileSync('./etc/test-key.pem');
serverOpts.cert = fs.readFileSync('./etc/test-cert.pem'); serverOpts.cert = fs.readFileSync('./etc/test-cert.pem');
server = https.createServer(serverOpts, expressApp);
} else {
server = http.createServer(expressApp);
} }
var server = protocol.createServer(serverOpts, expressApp);
console.log(config.enableHTTPS);
// Bootstrap models // Bootstrap models
var models_path = __dirname + '/app/models'; var models_path = __dirname + '/app/models';