Merge pull request #17 from ardavis/master

Add HTTPS Support fix #15 #17
pull/22/head v0.4.0
Maciej Winnicki 2013-06-20 10:06:46 -07:00
commit 0efceb288c
2 changed files with 26 additions and 11 deletions

View File

@ -20,16 +20,18 @@
Options:
-h, --help output usage information
-V, --version output the version number
-p, --port <port> server port, default 9001
-n, --number <number> starting lines number, default 10
-l, --lines <lines> number on lines stored in browser, default 2000
-d, --daemonize run as daemon
-U, --user <username> Basic Authentication username, this option works only along with -P option
-P, --password <password> Basic Authentication password, this option works only along with -U option
--pid-path <path> if run as daemon file that will store the process id, default /var/run/frontail.pid
--log-path <path> if run as daemon file that will be used as a log, default /dev/null
-h, --help output usage information
-V, --version output the version number
-p, --port <port> server port, default 9001
-n, --number <number> starting lines number, default 10
-l, --lines <lines> number on lines stored in browser, default 2000
-d, --daemonize run as daemon
-U, --user <username> Basic Authentication username, this option works only along with -P option
-P, --password <password> Basic Authentication password, this option works only along with -U option
-k, --key <key.pem> Private Key for HTTPS
-c, --certificate <cert.pem> Certificate for HTTPS
--pid-path <path> if run as daemon file that will store the process id, default /var/run/frontail.pid
--log-path <path> if run as daemon file that will be used as a log, default /dev/null
Web interface is on http://localhost:[port]

View File

@ -1,4 +1,5 @@
var program = require('commander')
, https = require('https')
, http = require('http')
, fs = require('fs')
, socketio = require('socket.io')
@ -20,6 +21,8 @@ program
.option('-d, --daemonize', 'run as daemon')
.option('-U, --user <username>', 'Basic Authentication username, this option works only along with -P option', String, false)
.option('-P, --password <password>', 'Basic Authentication password, this option works only along with -U option', String, false)
.option('-k, --key <path/to/key.pem>', 'Private Key for HTTPS', String, false)
.option('-c, --certificate <path/to/cert.pem>', 'Certificate for HTTPS', String, false)
.option('--pid-path <path>', 'if run as daemon file that will store the process id, default /var/run/frontail.pid',
String, '/var/run/frontail.pid')
.option('--log-path <path>', 'if run as daemon file that will be used as a log, default /dev/null',
@ -96,7 +99,17 @@ if (program.daemonize) {
});
});
var server = http.createServer(app).listen(program.port);
var server;
if (program.key && program.certificate) {
var options = {
key: fs.readFileSync(program.key),
cert: fs.readFileSync(program.certificate)
};
server = https.createServer(options, app).listen(program.port);
} else {
server = http.createServer(app).listen(program.port);
}
/**
* socket.io setup