NodeJs Deployment Setup for AWS
2. Check system time and set proper time
sudo timedatectl set-timezone Asia/Kolkata
sudo curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
4. Clone your project from Github
sudo git clone <user repo link>
5. Install pm2 (run app in background)
Follow the instructions to install and configure pm2
i. Installing Pm2 package globally
ii. Running server with Pm2 package
To make sure app starts when reboot pm2 startup ubuntu
iii. To restart server with Pm2 package
a. Shows the list of app running using Pm2 package
b. For checking status of app
6. Change security setting for accessing your website
Then click on [edit inbound rule] and add some rules
-
Add rule and edit port number as per your need
7. Install NGINX and configure
sudo nano /etc/nginx/conf.d/server.conf
-
Add the following to the location part of the server block
server {
listen 80;
server_name <here add your domain name>;
location / {
proxy_pass http://127.0.0.1:8000; # here your port number
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
sudo systemctl restart nginx
sudo systemctl status nginx
8. Add SSL with LetsEncrypt
Just select the operating system and your server setup in my case Os - Ubuntu20, Server - Nginx and follow there instructions
9. Your nodeJs application deployed successfully 🚀