0
votes

I need to deploy my app with HTTPS on the same server with Direct Admin

First, I set the port to 8443 and start the server with node index.js. The server says that it's running on port 8443. But when I try to access https:// domain . com:8443/socket.io/socket.io.js, the browser return an error message "ERR_CONNECTION_REFUSED"

After that, I set the port to 443 (as someone said that HTTPS can only run with port 443) and start the server with sudo node index.js. This time the server did not start and retunr lot of error

PROJECT_PATH/node_modules/dotenv/lib/main.js:45 let value = keyValueArr[2] || '' ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object. (PROJECT_PATH/index.js:16:25) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10)

How can I fix this?

1
recommend you to put nginx in front of node to handle HTTPS - ijse
Running on 443 (anything under 1024) you need root privileges. Indeed the best practice is to have a reverse proxy doing ssl offload (httpd, nginx, f5,..). For the conn refused - is your certificate trusted? - gusto2
I'm using CloudFlare to protect my domains. That was the problem: CloudFlare only allow some predefined ports. I changed the port into one of the port in the allowed list and it works fine. No sudo need so the error about Block-scoped declarations does not happen too :) - Hieu Nguyen

1 Answers

0
votes

You should deploy the reverse proxy(like: nginx) front of node service, all network or https configurations stuff will be process perfectly on that, node webserver just run in internal of server.