connect via ssh to vps -------------- ssh -i /home/xx/Desktop/id_rsa user@IPADDRESS ---------- secure copy files to vps ------------------ make sure logout session scp -i id_rsa index-secure.js user@IPADDY:/home/user/nodejs/index-secure.js scp -i id_rsa index.html user@IPADDY:/home/user/nodejs/index.html upgrade debian --------------- sudo apt update sudo apt upgrade password ----------------- change dir ----------- cd nodejs ----------- sudo apt install npm npm install express --save use 0.0.0.0 for public not 127.0.0.1 nano index.js --------------- const https = require('https'); const http = require('http'); const fs = require('fs'); const hostname = '0.0.0.0'; const port = 443; const domain ='domain' const options = { key: fs.readFileSync('/home/user/_.domain_private_key.key'), cert: fs.readFileSync('/home/user/domain_ssl_certificate.cer') }; https.createServer(options, function (req, res) { res.writeHead(200); res.end("hello world secured\n"); }).listen(port, hostname); // Redirect from http port 80 to https http.createServer(function (req, res) { res.writeHead(301, { "Location": "https://" + domain }); res.end(); }).listen(80); --------------- run process in background, connect, and kill daemon node js server ------------------------------------------------------------------ [5] 135928 cd nodejs sudo -v nohup sudo node index.js & see process running ------------------ ps -ef | grep node logout of vps while keeping process running poor man daemon systemd service ---------------------------------------------------------------------------- exit kill process -------------- pid process id ppid parent process id kill 25938 pkill -STOP -P the_ppid favicon convert ---------------- sudo apt install imagemagick convert image.png -background white \ \( -clone 0 -resize 16x16 -extent 16x16 \) \ \( -clone 0 -resize 32x32 -extent 32x32 \) \ \( -clone 0 -resize 48x48 -extent 48x48 \) \ \( -clone 0 -resize 64x64 -extent 64x64 \) \ -delete 0 -alpha off -colors 256 favicon.ico secure copy files to vps ------------------ make sure logout session scp -i id_rsa index.js user@IPADDY:/home/user/nodejs/index.js scp -i id_rsa index.html user@IPADDY:/home/user/nodejs/index.html list file sizes human readable ------------------------------- ls -l -h see what service is running on port 80 --------------------------------------- sudo lsof -i:80 stop apache2 server ------------------- sudo service apache2 stop sudo apt-get remove apache2 local vs secure tls difference ------------------------------ secure 0.0.0.0 :43 local 127.0.0.1 : 8000 http vs https reading certificate