diff --git a/CHANGELOG.md b/CHANGELOG.md index be681cbb..0debd80f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Added the ability to hide the temp label and weather icon in the `currentweather` module to allow showing only information such as wind and sunset/rise. - The `clock` module now optionally displays sun and moon data, including rise/set times, remaining daylight, and percent of moon illumination. - Added Hebrew translation. +- Add HTTPS support and update config.js.sample + ### Fixed - Force declaration of public ip adress in config file (ISSUE #1852) diff --git a/config/config.js.sample b/config/config.js.sample index c22960e5..01a41caa 100644 --- a/config/config.js.sample +++ b/config/config.js.sample @@ -21,6 +21,10 @@ var config = { // or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format : // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"], + useHttps: false, // Support HTTPS or not, default "false" will use HTTP + httpsPrivateKey: "", // HTTPS private key path, only require when useHttps is true + httpsCertificate: "", // HTTPS Certificate path, only require when useHttps is true + language: "en", timeFormat: 24, units: "metric", diff --git a/js/server.js b/js/server.js index b9c9b0d8..19bdfb91 100644 --- a/js/server.js +++ b/js/server.js @@ -7,8 +7,6 @@ var express = require("express"); var app = require("express")(); -var server = require("http").Server(app); -var io = require("socket.io")(server); var path = require("path"); var ipfilter = require("express-ipfilter").IpFilter; var fs = require("fs"); @@ -22,6 +20,18 @@ var Server = function(config, callback) { port = process.env.MM_PORT; } + var server = null; + if(config.useHttps){ + var options = { + key: fs.readFileSync(config.httpsPrivateKey), + cert: fs.readFileSync(config.httpsCertificate) + } + server = require("https").Server(options, app); + }else{ + server = require("http").Server(app); + } + var io = require("socket.io")(server); + console.log("Starting server on port " + port + " ... "); server.listen(port, config.address ? config.address : "localhost"); diff --git a/serveronly/index.js b/serveronly/index.js index 3b8013ef..f7da58f5 100644 --- a/serveronly/index.js +++ b/serveronly/index.js @@ -1,5 +1,6 @@ var app = require("../js/app.js"); app.start(function(config) { var bindAddress = config.address ? config.address : "localhost"; - console.log("\nReady to go! Please point your browser to: http://" + bindAddress + ":" + config.port); + var httpType = config.useHttps ? "https" : "http"; + console.log("\nReady to go! Please point your browser to: " + httpType + "://" + bindAddress + ":" + config.port); });