Thursday, July 26, 2018

centOS node SSL

 Express 4.0


The correct way to start your Express app is:

npm start


========================================
**************************************
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


install node.js

putty login 104.238.125.233




cd ~


wget https://nodejs.org/dist/v10.7.0/node-v10.7.0-linux-x64.tar.xz


tar xvf node-v10.7.0-linux-x64.tar.xz

mv node-v10.7.0-linux-x64 nodejs


mkdir ~/bin


cp nodejs/bin/node ~/bin

cd ~/bin

ln -s ../nodejs/lib/node_modules/npm/bin/npm-cli.js npm

node --version

npm --version



*************************************
===========================================





No need to install and run nginx



 sudo service nginx start

 sudo service nginx stop












========================================

******** start node.js app****************

if you want to use nodemon, fist install it
npm install -g nodemon


Installing PM2

$ npm install pm2 -g


cd  /home/transparentgov/public_html/arcgis_viewer/

PM2 now supports npm start:
pm2 start npm -- start

http://pm2.keymetrics.io/

pm2 list

list all process.......

pm2 stop  0
pm2 restart  0
pm2 delete  0






******** start node.js app****************
========================================




node express add SSL



1)
download private key file from cpanel ----- ssl/STL ---- private key---
click edit, copy encoded part into a new file. Save to /bin/www/private.key

2)
download certificate file, from godaddy, my product, SSL,
click download button, choose other type.

Only 1 file xxxx.crt is the one we need, copy to  /bin/www/public.cert



3)
/bin/www  file add https code.

// readFileSync function must use __dirname get current directory
// require use ./ refer to current directory.


// ----- https ----------

const https = require('https');
const fs = require('fs');

// readFileSync function must use __dirname get current directory
// require use ./ refer to current directory.

const options = {
key: fs.readFileSync(__dirname + '/private.key', 'utf8'),
cert: fs.readFileSync(__dirname + '/public.cert', 'utf8')
};


var port = normalizePort(process.env.PORT || '3200');
app.set('port', port);


// Create HTTPs server.

var server = https.createServer(options, app);


// ----- End ------ https ----------

















No comments: