Can't access site on EC2 instance via public i

2019-01-29 18:27发布

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.

8条回答
唯我独甜
2楼-- · 2019-01-29 19:08

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

Rules

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

enter image description here

  • Once you are happy it's working I would probably replace all traffic with HTTP and HTTPS if that's all that is needed
查看更多
smile是对你的礼貌
3楼-- · 2019-01-29 19:09

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.

查看更多
来,给爷笑一个
4楼-- · 2019-01-29 19:11

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.

查看更多
The star\"
5楼-- · 2019-01-29 19:14

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.

查看更多
看我几分像从前
6楼-- · 2019-01-29 19:17

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
查看更多
劫难
7楼-- · 2019-01-29 19:19

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
查看更多
登录 后发表回答