Merge pull request #1915 from normankong/develop

Support HTTPS Magicmirror (resubmit)
This commit is contained in:
Michael Teeuw 2020-02-06 10:10:06 +01:00 committed by GitHub
commit 30e93a9372
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 3 deletions

View File

@ -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. - 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. - The `clock` module now optionally displays sun and moon data, including rise/set times, remaining daylight, and percent of moon illumination.
- Added Hebrew translation. - Added Hebrew translation.
- Add HTTPS support and update config.js.sample
### Fixed ### Fixed
- Force declaration of public ip adress in config file (ISSUE #1852) - Force declaration of public ip adress in config file (ISSUE #1852)

View File

@ -21,6 +21,10 @@ var config = {
// or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format : // 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"], // ["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", language: "en",
timeFormat: 24, timeFormat: 24,
units: "metric", units: "metric",

View File

@ -7,8 +7,6 @@
var express = require("express"); var express = require("express");
var app = require("express")(); var app = require("express")();
var server = require("http").Server(app);
var io = require("socket.io")(server);
var path = require("path"); var path = require("path");
var ipfilter = require("express-ipfilter").IpFilter; var ipfilter = require("express-ipfilter").IpFilter;
var fs = require("fs"); var fs = require("fs");
@ -22,6 +20,18 @@ var Server = function(config, callback) {
port = process.env.MM_PORT; 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 + " ... "); console.log("Starting server on port " + port + " ... ");
server.listen(port, config.address ? config.address : "localhost"); server.listen(port, config.address ? config.address : "localhost");

View File

@ -1,5 +1,6 @@
var app = require("../js/app.js"); var app = require("../js/app.js");
app.start(function(config) { app.start(function(config) {
var bindAddress = config.address ? config.address : "localhost"; 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);
}); });