Problem:
You have created an EC2 instance. Need to understand how to work with Security groups.
Solution Summary:
We will remove rule for HTTP from our security group and try running public IP again.
Prerequisites:
This lab assumes that you can create an EC2 instance, connect to it and do basic operations.
Solution Steps:
-
Create an EC2 instance of type t2 micro. Reuse the security group and the keypair we had created in previous labs. Note: You may also create a new security group, but allow HTTP and HTTPS in addition to SSH.
-
Login using the public ip through SSH, and elevate as root:
-
sudo su
-
-
Install and start apache server
-
yum install httpd –y
-
service httpd start
-
checkconfig httpd on (this steps is required to start httpd automatically every time we reboot)
-
Go to the html directory of the apache server
-
cd /var/www/html
-
-
Create a very small html file:
-
vi index.html
-
click on insert or i.
-
Type: <html><h1>Hello Buddy!</h1></html>
-
Click on ESC, type :x, and press enter to save
-
-
Verify getting the html output:
-
Copy the public ip for the instance from the console
-
Run it on the browser after http (e.g. http://54.71.189.78/). You should see the web page with: Hello Buddy!
-
-
-
Go back to EC2’s Security Groups section, select the security group we are using and remove rule for HTTP. It will be immediately reflected: try running the public ip url again and it will not display the page.
Comments
notes on step3.3-
step3.3- checkconfig httpd on
Above command doesn't work on windows machines.
Try this instead : chkconfig httpd on