AWS: connect EC2

less than 1 minute read

  1. Run Git Bash as administrator
  2. Connect EC2 ` $ ssh ec2-user@public-ip-address -i ec2keypair.pem`
  3. Remove old directory $ rm -rf xx
  4. Clone new repository: git clone https://github.com/LiMarcus/myWeb.git
  5. npm install -g pm2
  6. check current status: pm2 list
  7. kill all process pm2 kill
  8. remove npm remove pm2 -g
  9. pm2 start app.js
  10. pm2 save
  11. pm2 startup
  12. Nginx

My front end send https request to EC2 balancer, the balancer has a function to convert https to http then send to instance, after that, I use Nginx to redirect http request to port 8888;

Actually, Nginx can handle https request, we can set SSL in Nginx; But I choose using AWS certificate, the disadvatange is this certificate can only deploy on EC2 balancer, then use balancer send requset to each instance;

sudo nano /etc/nginx/nginx.conf

nginx.conf

load balancer

load balancer

Updated: