Troubleshooting AWS EC2 not serving 80/443

Vis1/0N

Expert Member
Joined
Mar 10, 2009
Messages
2,746
Reaction score
552
Location
Durban
I am not experienced with any of this. I have installed an AWS EC2 instance (ubuntu 22.04) but it does not serve the pages. I have install ed nginx but cannot reach the default page.

systemctl status nginx is showing the nginx is active.
Just calling nginx from the terminal I am getting a set of errors along the line nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)

I have an elastic IP attached to the instance, and have opened the relevant ports via the security groups. For example whilst troubleshooting I decided to test webmin, and I have correctly opened port 10000 and can access the webmin page via [MyElasticIP]:10000. I cannot access the nginx default page http://[MyElasticIP]:80 though.

I did not initially open ports 80/443 during the EC2 instance setup though. I don't know if I missed anything. The Inbound rules look correct. Any ideas on how to troubleshoot this?

Edit : Adding 8080 to Inbound rules on the same security group, UFW allow 8080, and listen 8080 allows me to view the page correctly. Port 80 from the same group - is it being blocked elsewhere?
 
Last edited:
There is probably a reject rule in the iptables.
 
Will look into it, I did run a iptables -L -n -v command earlier today and it shows throughput on ssh, webmin and 8080 ports (51822 is also working, 51820 was not used)

Chain ufw-user-input (1 references)
pkts bytes target prot opt in out source destination
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:51820
51 3016 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22 /* 'dapp_OpenSSH' */
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:51822
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:443
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:443
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 /* 'dapp_Nginx%20HTTP' */
60 3120 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:10000
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:10000
3 156 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:8080
 
I am not experienced with any of this. I have installed an AWS EC2 instance (ubuntu 22.04) but it does not serve the pages. I have install ed nginx but cannot reach the default page.

systemctl status nginx is showing the nginx is active.
Just calling nginx from the terminal I am getting a set of errors along the line nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error)

I have an elastic IP attached to the instance, and have opened the relevant ports via the security groups. For example whilst troubleshooting I decided to test webmin, and I have correctly opened port 10000 and can access the webmin page via [MyElasticIP]:10000. I cannot access the nginx default page http://[MyElasticIP]:80 though.

I did not initially open ports 80/443 during the EC2 instance setup though. I don't know if I missed anything. The Inbound rules look correct. Any ideas on how to troubleshoot this?

Edit : Adding 8080 to Inbound rules on the same security group, UFW allow 8080, and listen 8080 allows me to view the page correctly. Port 80 from the same group - is it being blocked elsewhere?
Test your configuration on the instance by running something like

Code:
curl http://localhost -vvv

If that succeeds at least you know locally port 80 is bound and responding locally.
Next up you can consider launching another instance in the same AZ and subnet and see if you can get a response by running the same curl command (but obviously instead of localhost the IP of the host running nginx)

If both of those succeed then your problem is your VPC configuration.
Check that your Security Group, Subnet, VPC and so on doesn't have explicit blocks for the typically protected ports (ie < 1024)
 
Yep curl was giving a correct response on localhost. I was wondering if there was a chance that the elastic IP was being blocked on 80/443, everything else seems correct. I might try another elastic IP when I get the chance.

I have a lightsail instance that is functioning correctly but that is on my personal account. I mostly mirrored what was necessary onto the EC2 instance. I could start over, but it seems like a cop out to understand what is not working.
 
Top
Sign up to the MyBroadband newsletter
X