DEV Community

Kew Coder
Kew Coder

Posted on

Simple run Node JS App in VPS Server NginX with SSL

Node Js Nginx Server

apt update && apt upgrade

apt -y install nginx

apt install software-properties-common
add-apt-repository universe
add-apt-repository ppa:certbot/certbot

apt update

apt -y install python-certbot-nginx

nano /etc/nginx/sites-available/

server {
listen 80;

location / {
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;

sudo ln -s /etc/nginx/sites-available/  /etc/nginx/sites-enabled/

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled

sudo nginx -t && sudo systemctl restart nginx

certbot --nginx -d

sudo apt install nodejs

sudo apt install npm

npm install pm2 -g

pm2 start server.js

run project with pm2 to localhost:8000

Discussion (0)