Tomcat – How to access Amazon EC2 instance by HTTP

amazon ec2tomcat

I have installed Amazon EC2 instance and have set up tomcat7 on it with sudo yum install tomcat7 command. Also I have added a rule

8080 0.0.0.0/0

in instance's security group.

Also I ran tomcat7 service and now

$ service tomcat7 status
tomcat7 (pid 3979) is running...                           [  OK  ]

But I still cannot access tomcat's greeting page:

$ wget http://localhost:8080
--2012-05-21 19:33:56--  http://localhost:8080/
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... 404 Not Found
2012-05-21 19:33:56 ERROR 404: Not Found.

What else should be done?

REMOTE ACCESS

Also I get "network unreacheable" error while trying to access the server from my home computer.

>wget http://<DNS>.amazonaws.com:8080
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = c:/progra~1/wget/etc/wgetrc
--2012-05-21 23:37:35--  http://<DNS>.amazonaws.com:8080/
Resolving <DNS>.amazonaws.com... xxx.xx.xxx.xxx
Connecting to <DNS>.amazonaws.com|<IP>|:8080... failed: Network is unreachable.

Best Answer

Given that you're running wget locally from the ec2 instance itself, the security group is of no significance. The fact that you're getting a 404 implies that tomcat is indeed serving your request. It is another matter that tomcat is returning a Page Not Found error.

Two things: 1) For local access to an ec2 instance (from the instance itself that is), security groups do not have any significance. And there you are clearly able to reach tomcat. Just that tomcat is returning a 404 Not Found instead of the greeting page.

2) Remote access is controlled by security group. But given that you're seeing a Netwok Unreachable error, it looks like a routing table issue.

Related Topic