MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Re: Run MagicMirror https

    Scheduled Pinned Locked Moved Unsolved Feature Requests
    know
    1 Posts 1 Posters 289 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      accountnumber3
      last edited by

      Re: Run MagicMirror https

      I didn’t see where the previous request was closed and the forum automatically suggested I create a new topic, so here:
      also I’m kinda scatterbrained right now so please ask questions if something isn’t clear

      How to configure HTTPS

      Based on this post:
      https://forum.magicmirror.builders/topic/8469/how-to-run-as-https

      Lines that are commented out (#) are pre-existing, shown for location reference only. They should not actually be commented out.
      Lines that are commented out (//) can be toggled based on preference.

      config/server.js

      var fs = require("fs");
      #var express = require("express");
      #var app = require("express")();
      var options = {
      	key: fs.readFileSync("config/certs/mirror.key"),
      	cert: fs.readFileSync("config/certs/mirror.crt")
      };
      //var server = require("http").Server(app);
      var server = require("https").Server(options, app);
      

      config/config.js

      #var config = {
      #address: "0.0.0.0", // Address to listen on, can be:
      #port: 8088,
      #ipWhitelist: [], // Set [] to allow all IP addresses
      useHttps: false,
      httpCerts: {
          path: "config/certs",
          cert: "config/certs/mirror.crt",
          key: "config/certs/mirror.key",
          port: 4433,
      },
      

      Problem:

      • config.js is loaded inside var Server, wayyyyy down at the bottom.
      • var options must be defined prior to var server (not the same as var Server)
      • this means that any settings must be defined directly inside server.js, which will be overwritten when updating MM.
      • because of this, config.js is actually completely useless here. I’m including it as an example of what it should look like if this actually worked.

      Solution:

      I don’t know node.js, or really javascript. My first instinct is to extract the config definition to the very top of the file. But it seems like the config is loaded via the server, and I’m trying to define the server via the config. I tried to run a squid proxy server to handle https but I couldn’t figure that out. Maybe the answer is to run HTTP and HTTPS simultaneously. Maybe you could have an ipWhitelist for each if you wanted to restrict HTTP access but not HTTPS. To be honest though, I think the whitelist should be handled by the OS’s firewall. iptables isn’t that difficult.
      For the record, I’m using node serveronly and pushing to a chromecast via catt through cron.

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Enjoying MagicMirror? Please consider a donation!
      MagicMirror created by Michael Teeuw.
      Forum managed by Sam, technical setup by Karsten.
      This forum is using NodeBB as its core | Contributors
      Contact | Privacy Policy