Based on this tutorial, here's an updated step by step:
1) Make an account on Amazon Web Services.
2) Create an EC2 instance; I chose Ubuntu micro.
3) Configure Security Group (name it "Node") and add ports:
HTTP (80), HTTPS (443), and a custom TCP port for your Node app (e.g. 3000)
4) Launch the instance and save the pem file (private key), e.g. "node.pem".
5) On Windows - install Cygwin + OpenSSH package. it is also recommended to install WinScp to have "explorer like" access to the linux.
6) Open Cygwin Terminal as Administrator, and set correct permissions to "node.pem" file:
chown :Users node.pem
chmod 400 node.pem
7) Find your EC2 instance public DNS name in the EC2 dasboard, and connect to it with SSH:
ssh -i node.pem ubuntu@{your EC2 public DNS name}
8) Update Ubuntu and install NodeJS:
sudo apt-get update
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential
9) Copy your NodeJS application into the EC2 instance (via Cygwin, or Winscp).
10) Install all of your Node app required modules:
cd /home/ubuntu/My_Node_App
npm install --save
11) Re-route ports with IPtables so that your app can be accessed on default http port 80:
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000
To view the iptables routing entries, run:
sudo iptables -t nat -L
If you need to remove routing entry (first line), run:
sudo iptables -t nat -D PREROUTING 1
12) Run your app as a background process:
sudo nohup node app.js &
To kill your app process:
ps -ef | grep app.js
sudo kill {proccess id number}