Control Web Panel

WebPanel => Addons => Topic started by: simpli on July 02, 2021, 01:57:11 PM

Title: nodejs SSL
Post by: simpli on July 02, 2021, 01:57:11 PM
Hi there,

I hope someone can advise me on the nodejs SSL issue with private key and certificate file permission denied.

My current code as follow:-
Code: [Select]
const hostname = '';
const port = 300;

const fs = require('fs');
const privateKey = fs.readFileSync("/etc/pki/tls/private/", 'utf8')
const certificate = fs.readFileSync("/etc/pki/tls/certs/", 'utf8')
const credentials = {
    key: privateKey,
    cert: certificate

const httpServer = require('https').createServer( credentials, (req, res) => {
  res.statusCode = '200';
  res.setHeader('Content-Type', 'text/plain');
  res.end('Welcome port '+ port)
} );

httpServer.listen(port, hostname, () => {
  console.log('listening to : '+ port);

If i try to point to /etc/pki/tls folders this app will prompt permission denied error.
Currently, i manually copy these files to the app folder and i have to keep repeating this process everytime the AutoSSL expired.

Please advise how may i use this files without manually copy it into the app folder.

Thank you in advance.

Stay home and stay safe.
Title: Re: nodejs SSL
Post by: mrmorales on July 02, 2021, 02:25:09 PM
Hello, this app have a domain associated?? I think if you binf a domain to the app and that domain is under an SSL it will work.
Title: Re: nodejs SSL
Post by: studio4host on July 03, 2021, 07:16:56 AM
that is why you have nginx/apache proxy setup via webservers domain conf module in admin where you can set https so you don't need to configure nodejs https.