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
This commit is contained in:
dintho 2025-03-10 17:03:48 -06:00 committed by GitHub
parent befa9a5c25
commit a130d6c9e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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');