Skip to content

Commit a130d6c

Browse files
authored
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
1 parent befa9a5 commit a130d6c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

services/healthcheck.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@
44
* Note that exiting with code 1 indicates failure, and 0 is success
55
*/
66

7-
const isSsl = !!process.env.SSL_PRIV_KEY_PATH && !!process.env.SSL_PUB_KEY_PATH;
7+
const fs = require('fs');
8+
/* setting default paths for public and pvt keys to match of ssl-server.js */
9+
const httpsCerts = {
10+
private: process.env.SSL_PRIV_KEY_PATH || '/etc/ssl/certs/dashy-priv.key',
11+
public: process.env.SSL_PUB_KEY_PATH || '/etc/ssl/certs/dashy-pub.pem',
12+
};
13+
14+
/* Check if either if simular conditions exist that would of had ssl-server.js to enable ssl */
15+
const isSsl = !!fs.existsSync(httpsCerts.private) && !!fs.existsSync(httpsCerts.public);
816

917
// eslint-disable-next-line import/no-dynamic-require
1018
const http = require(isSsl ? 'https' : 'http');

0 commit comments

Comments
 (0)