makes you really appreciate gh-pages, now.sh and other deployment services that don't force you to setup your own virtual machine. - author
non-fat notes based on this blogpost
Welcome to Alibaba Cloud Elastic Compute Service !sudo apt-get update makes sure you get to download gitsudo apt-get install git downloads gitcurl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh downloads a .sh file (to setup node)sudo bash nodesource_setup.shinstalls the stuff needed to install nodesudo apt-get install -y nodejscurl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarnsudo apt-get install nginx installs nginx to serve nodenpm i -g pm2 installs PM2 Process Manager (monitors for crashes, autoscales node)cd /homegit clone https://github.com/<YOU MY DEAR READER>/<YOUR GITHUB REPO>.gitcd <YOUR GITHUB REPO> enter the folder you just git clonednpm install or yarn install installs your npm packagesthe author of the reference blogpost has a more complex application in mind, so if you have other stuff like .env files or mongodb to deal with, refer to that.
nano /etc/nginx/sites-available/default to open the nano editorserver {
listen 80;
server_name <YOUR ECS INSTANCE'S PUBLIC IP ADDRESS>;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
}
}<ECS IP ADDRESS> and give it to http://localhost:3000 which is your nodejs app.you can replace the <YOUR ECS INSTANCE PUBLIC IP ADDRESS, 47.XX.XXX.XXX> with your domain name if you have one, but i don't, so i'm using the ip address.
sudo systemctl restart nginx restarts nginx (my nginx failed here)cd /home/<YOUR NODEJS APP>pm2 start index.js --name "my-node-app" starts your node app, like gunicorn for your flask/nginx deployments