| Server IP : 175.110.121.100 / Your IP : 10.10.10.2 Web Server : Apache/2 System : Linux webserver 6.12.0-211.34.1.el10_2.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 15 07:56:02 EDT 2026 x86_64 User : webadmin ( 1000) PHP Version : 8.3.31 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/webadmin/public_html/services/ |
Upload File : |
const fs = require('fs');
const util = require('util');
const https = require('https');
const promise = util.promisify;
const stat = promise(fs.stat);
const host = process.env.HOST || '0.0.0.0';
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',
};
const isDocker = !!process.env.IS_DOCKER;
const SSLPort = process.env.SSL_PORT || (isDocker ? 443 : 4001);
const redirectHttps = process.env.REDIRECT_HTTPS ? process.env.REDIRECT_HTTPS : true;
const printNotSoGood = (msg) => {
console.log(`SSL Not Enabled: ${msg}`);
};
const printSuccess = () => {
console.log(`🔐 HTTPS server successfully started (port: ${SSLPort} ${isDocker ? 'of container' : ''})`);
};
// Check if the SSL certs are present and SSL should be enabled
let enableSSL = false;
const checkCertificateFiles = stat(httpsCerts.public).then(() => {
return stat(httpsCerts.private).then(() => {
enableSSL = true;
}).catch(() => { printNotSoGood('Private key not present'); });
}).catch(() => { printNotSoGood('Public key not present'); });
const startSSLServer = (app) => {
checkCertificateFiles.then(() => {
// If SSL should be enabled, create a secured server and start it
if (enableSSL) {
const httpsServer = https.createServer({
key: fs.readFileSync(httpsCerts.private),
cert: fs.readFileSync(httpsCerts.public),
}, app);
httpsServer.listen(SSLPort, host, () => { printSuccess(); });
}
});
};
const middleware = (req, res, next) => {
if (enableSSL && redirectHttps && req.protocol === 'http') {
res.redirect(`https://${req.hostname + ((SSLPort === 443) ? '' : `:${SSLPort}`) + req.url}`);
} else {
next();
}
};
module.exports = { startSSLServer, middleware };