Tuesday, March 11, 2014

Deploying Node.js Express application on AWS

AWS provides a free account for experimenting with their cloud.

Joyent is a competitor in terms of deploying Node.js applications.

Node.js + MongoDB = Awesome at Joyent (+ mongoLab).

Today I deployed my website on aws ec2.

Here are the steps:

1) Create an account on amazon.
2) Goto dashboard.
3) Create a new instance of amazon ec2. (its very intuitive and easy to use, lots of resources on google.)

4) Rerouting inbound port 80 to whichever port you are using in your application.
steps:
a) sudo bash
b) iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
c) Save to a file:
    iptables-save > /etc/iptables-up.rules
d) save it to startup configuration file:
echo "post-up /sbin/iptables-restore < /etc/iptables-up.rules" >> /etc/network/interfaces
e) Done.

5)Install node.js from there github repository.
take the stable release branch: https://github.com/joyent/node/tree/v0.10.26-release

6) install npm, express, mongoDB or any other modules you want to.

7) clone your application

8) Go back to aws. Goto security groups.
a) Add All ICMP port with source whatever you like or keep as default.
b) Open TCP port 3000.

9) Goto amazon ec2 instance. Spin your application.
10) Enter your public DNS with your port (here it is 3000).
11) Enjoy!

No comments:

Post a Comment