How to open port 80 on AWS EC2

Viewed 1553

I want to open port 80 to allow HTTP connections on my EC2 server. But when I'm entering "telnet xx.xx.xx.xx 80" on a terminal the following is displayed

"Trying xx.xx.xx.xx..." 
telnet: Unable to connect to remote host: Connection timed out

In AWS I've opened port 80 by defining an Inbound Rule on the Security group (only one security group is defined for this EC2 server)

enter image description here

enter image description here

I'm using the Public IPv4 address to make a telnet connection

enter image description here

1 Answers

I noticed you have a fresh install -- fresh installs do not have software listening over HTTP by default.

If there is no application listening on a port, incoming packets to that port will simply be rejected by the computer's operating system. Ports can be "closed" through the use of a firewall, which you have disabled, therefore the ports are open just unresponsive which makes them appear closed.

If the port is enabled in the firewall in terminal using

sudo apt-get install ufw
sudo ufw allow ssh
sudp ufw allow https
sudo ufw allow http
sudo reboot

and enabled in the aws console as a rule, the port is open and just not responsive so it's seen as closed. By installing either nginx or something that binds to port 80, external requests to that port will be connected successfully, and the port will therefore be recognized as open. The reason ssh is recognized as open is because 1. it has firewall transparency, and 2. it is always listening (unlike port 80!). Before installing nginx even though ports are allowed thru firewall: enter image description here

sudo apt-get install nginx
sudo ufw allow 'Nginx HTTP'
sudo systemctl status nginx

(more nginx info)

After: enter image description here

Simple port tester tool here

Related