mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Add HTTPS support
This commit is contained in:
parent
4c2a9b47f5
commit
c8c327b6ab
@ -5,6 +5,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
❤️ **Donate:** Enjoying MagicMirror²? [Please consider a donation!](https://magicmirror.builders/donate) With your help we can continue to improve the MagicMirror² core.
|
||||
|
||||
## [2.12.0] - 2020-01-31
|
||||
|
||||
### Changed
|
||||
- Add HTTPS support and update config.js.sample
|
||||
|
||||
## [2.11.0] - 2020-01-24
|
||||
|
||||
### Changed
|
||||
|
@ -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
|
||||
httpsPrivateKey: "", // HTTPS Private Key path
|
||||
httpsCertificate: "", // HTTPS Certificate path
|
||||
|
||||
language: "en",
|
||||
timeFormat: 24,
|
||||
units: "metric",
|
||||
|
14
js/server.js
14
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");
|
||||
|
@ -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);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user