Can't access site on EC2 instance via public i

2019-01-29 18:21发布

问题:

I've been experimenting with EC2 for a couple days and have been banging my head against simply even being able to access the sample site I've hosted. The stack is Rails 3.1.3 with Thin and Nginx.

I've tried several different configurations and finally ended up running the Nginx auto install script, which does return a webpage when I do a curl http://ec2-107-20-143-179.compute-1.amazonaws.com/. However, when I point my browser there, it hangs forever before saying the page cannot be found.

I have assigned an Elastic IP address, and I've enabled HTTP access via port 80.

I don't much experience with the sysadmin side and I'm basically stumped at this point. Any advice would be greatly appreciated.

回答1:

Did you enable the http port to all ips? That would be done by going to:

EC2 -> Security Group -> Default (or your custome one) -> Inbound

And then Create a new rule for HTTP and as a source, you should assign: 0.0.0.0/0

That should do it.



回答2:

Think the AWS UI may have been updated but based on Deleteman's answer

  • Login to EC2 Dashboard
  • Instances > Instances
  • Actions dropdown > Networking > Change security groups
  • You will probably see that you only have launch-wizard-1 allowed which for me only allowed SSH access on port 22

So as Deleteman mentions, you may need to alter your security groups...

  • Login to EC2 Dashboard
  • Network and Security > Security Groups
  • Remove any filters that may be in the search box to show all groups
  • Personally I edited the default VPC security group as this is a sandbox for me, I imagine you'll want to create a security group for your project
  • Select the security group checkbox, select actions dropdown and click "edit the inbound rules", I used the following inbound rules just to be sure it was all working

  • When you revisit Instances > Instances > Description, you should see the security groups and the rules

  • Once you are happy it's working I would probably replace all traffic with HTTP and HTTPS if that's all that is needed


回答3:

I was here earlier looking for a solution to a similar problem I was having. It turns out in my case that the EC2 instance also had its own firewall running in addition to the EC2 security group. The command 'system-config-firewall' let me get in to open the ports. Ports 80 (HTTP) and 3306 (MySQL) were not open by default. 22 (SSH) was open. I also had to do 'yum install system-config-firewall'.

To summarize, my solution was:

> yum install system-config-firewall
> system-config-firewall


回答4:

This answer is for the newbies who have no idea what they are doing with an ec2 instance.

I was having the same problem and tried all the Security Group fixes to no avail.

As it turns out, I needed to turn on my server from the command line.

sudo service httpd start 

Sometimes it's dark, not because a fuse blew, but because you didn't flick the switch.



回答5:

I was also struggling with same problem had created security group as well, but did not applied to the instance. Just create new rule for http. And apply from right click instance and choose security group and assign it.



回答6:

Octopus' answer was the correct one for me, except for a Windows machine. I needed to go to the Windows Firewall, was blocking all traffic out of the VM if it didn't match a rule. Port 80 wasn't enabled in a rule, so I merely had to add one.



回答7:

Very stupid of me as I forgot to install web server (HTTP server) because of which my ec2 instance public IP was not working. Answering this question as this can also be one of the reason which one should not miss as I did.

You can install either,

nginx:

sudo apt-get install nginx

apache2:

sudo apt-get install apache2


回答8:

I had the same issue, been racking my brain bad since I have no experience with Ubuntu or linux. The answer from Parag fixed it.

Very stupid of me as I forgot to install web server (HTTP server) because of which my ec2 instance public IP was not working. Answering this question as this can also be one of the reason which one should not miss as I did.

You can install either,

nginx:

sudo apt-get install nginx

apache2:

sudo apt-get install apache2