简体   繁体   中英

Amazon aws ec2 network tomcat issue

I had the same problem as many others not being able to connect to tomcat port 8080

I had tried everything suggested eg security groups.

What I then did was I created the amazon linux instance (instead of the redhat)

And this worked !! I did the same thing for both instances: added tcp port 8080 in security group

Looking at my iptables does this give a clue?

Bad redhat instance sudo iptables -L

[ec2-user@ip-172-31-37-61 ~]$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Good amazon linux:

[ec2-user@ip-172-31-36-174 ~]$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

It was frustrating for a couple of hours but now with Amazon-linux working I can proceed again. whew!

Thanks

My EC2 Security Group Inbound Configurations are as follows and port 8080 works fine. It should be Type-Custom TCP Rule, Protocol- TCP

The below image will show you a screen shot of my EC2 Security Group Inbound Configurations 截图

This is the current contents of iptables including my latest attempt to open 8080

[ec2-user@ip-172-31-37-61 ~]$ sudo cat /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
COMMIT

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM