AWS EC2 & Ubuntu - sandeepvalapi/DevOps GitHub Wiki
###System credentials:###
-
Login to aws.amazon.com.
-
Use credentials provided.
-
Select EC2.
-
Select EC2 Instances.
-
Click on each instance for more details.
-
Use super putty or putty for logging into remote.
Since we are using AWS Free tier, all the machines are being running on Ubuntu 14.04 OS. Each instance runs on 1 GB RAM.
###Creating Ubuntu AWS instance 👍 ###
-
EC2 Dashboard -> Create Instance will create new AWS instance.
-
After selecting Launch Instance, there are sequence of steps to create instance. AWS will ask us to select any one of the servers-> here select Ubuntu. Complete sequence of steps
-
Once completed the process we need to check the security group. This option will enable incoming and outgoing ports to the network.
-
After creating new instance, on selecting of one instance will show us complete details of the instance.
-
Use Putty for connecting to created AWS instance. Create a PPK file and use the PPK during Login. Futher information will be provided with AWS by Right Click on the instance.
-
After logging into the remote system, we need to enable ports to public URL. By default the IP is local I.e: 127.0.0.1 we need to make it 0.0.0.0
-
There are some helpful steps below 👍
#to save the rules you have created and to load them when the server starts. sudo apt-get install iptables-persistent sudo service iptables-persistent start #the rule that explicitly accepts your current SSH connection sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT #block all incoming traffic, except for those: 22 for SSH and 80 for web traffic sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT #block the remaining traffic sudo iptables -A INPUT -j DROP #allow loopback access sudo iptables -I INPUT 1 -i lo -j ACCEPT #save changes sudo /etc/init.d/iptables-persistent save #allow port 8080 sudo iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT sudo /etc/init.d/iptables-persistent save -
Below are some helpful links that can be used during port enable :
http://stackoverflow.com/questions/21966082/cannot-access-tomcat-instance-installed-in-ec2
http://stackoverflow.com/questions/9604840/how-to-configure-direct-http-access-to-ec2-instance
https://mobiarch.wordpress.com/2012/07/30/running-jboss-as-7-on-amazon-ec2/
Port forwarding in Ubuntu 👍
iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
The above step will forward 80 requests to 8080 port sudo netfilter-persistent save sudo netfilter-persistent reload
Configure Ngnix in ubuntu 👍
You should look at using a reverse proxy, such as Nginx. Put this in your nginx.config file
server {
listen 80;
server_name your_ip_address your_server_name
access_log /var/log/nginx/your_domain/access.log ;
error_log /var/log/nginx/your_domain/error.log info ;
location / {
proxy_pass http://127.0.0.1:3000; # pass requests for dynamic content to Rails app
}
}