From a130d6c9e6aa36f2bbc80497a46f1401e17aef88 Mon Sep 17 00:00:00 2001 From: dintho Date: Mon, 10 Mar 2025 17:03:48 -0600 Subject: [PATCH] Adjusting SSL Portion of HealthCheck I ran into a issue running dashy in a podman oci container with the default value for public & private key paths not being set the same way in healthcheck.js vs ssl-server.js This difference was allowing SSL to start causing the healthcheck to get a 302 redirect to https . This change adds in the same default path vars and i am going to say similar behavior that ssl-server.js uses. i tried to match the same style as the existing code between the two files another alternative is to set `SSL_PUB_KEY_PATH` and `SSL_PRIV_KEY_PATH` in the compose file as env vars but after seeing #843 which lead me #768 and then finding #1410 ill be honest this probably solves #843 and #1410 i dont think this totally solved #768 tbh. i had a hard time following that thread --- services/healthcheck.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/healthcheck.js b/services/healthcheck.js index a869b64f..86a3b75d 100644 --- a/services/healthcheck.js +++ b/services/healthcheck.js @@ -4,7 +4,15 @@ * Note that exiting with code 1 indicates failure, and 0 is success */ -const isSsl = !!process.env.SSL_PRIV_KEY_PATH && !!process.env.SSL_PUB_KEY_PATH; +const fs = require('fs'); +/* setting default paths for public and pvt keys to match of ssl-server.js */ +const httpsCerts = { + private: process.env.SSL_PRIV_KEY_PATH || '/etc/ssl/certs/dashy-priv.key', + public: process.env.SSL_PUB_KEY_PATH || '/etc/ssl/certs/dashy-pub.pem', +}; + +/* Check if either if simular conditions exist that would of had ssl-server.js to enable ssl */ +const isSsl = !!fs.existsSync(httpsCerts.private) && !!fs.existsSync(httpsCerts.public); // eslint-disable-next-line import/no-dynamic-require const http = require(isSsl ? 'https' : 'http');