Skip to content

Commit 3c5177d

Browse files
authored
Update health-check to support SSL properly
1 parent 37f0a66 commit 3c5177d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

services/healthcheck.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@
44
* Note that exiting with code 1 indicates failure, and 0 is success
55
*/
66

7-
const http = require('http');
7+
const isSsl = !!process.env.SSL_PRIV_KEY_PATH && !!process.env.SSL_PUB_KEY_PATH;
8+
9+
const http = require(isSsl ? 'https' : 'http');
810

911
/* Location of the server to test */
10-
const port = process.env.PORT || !!process.env.IS_DOCKER ? 80 : 4000;
12+
const isDocker = !!process.env.IS_DOCKER;
13+
const port = isSsl ? (process.env.SSL_PORT || (isDocker ? 443 : 4001)) : (process.env.PORT || isDocker ? 80 : 4000);
1114
const host = process.env.HOST || '0.0.0.0';
1215
const timeout = 2000;
1316

14-
const requestOptions = { host, port, timeout };
17+
const agent = new http.Agent({
18+
rejectUnauthorized: false, // Allow self-signed certificates
19+
});
20+
21+
const requestOptions = { host, port, timeout, agent };
1522

1623
const startTime = new Date(); // Initialize timestamp to calculate time taken
1724

0 commit comments

Comments
 (0)