How to make Tomcat on AWS EC2 accessible from outside the local host

I am trying to run Tomcat on an AWS Linux server. I installed Tomcat and tested it from the command line to make sure it works, but I cannot access it from another machine. Details:

  • The instance has port 80 inbound for HTTP, open in the security group.
  • I checked that it works on port 80, telnetting to localhost on that port, and does a GET request.
  • I tried adding public DNS as an alias for localhost in server.xml and then restarting to make sure the changes were matched.

However, if I try to access it through my browser (outside the real server) using the public DNS, I get "unable to connect."

Any ideas?

Thanks...

+7
source share
4 answers

OK, the problem turned out to be that I also needed to edit and restart iptables, as described here: http://cyberciti.biz/faq/howto-rhel-linux-open-port-using-iptables

+5
source

Did you open port 80?

when you create your instance, you select a security group for it.

go to the security groups on the left side, click on the group of your instance and the reverse side, in the inbox tab, you will set:

  • create a new rule: HTTP
  • Source: 0.0.0.0/0

clic add rule and click to apply rule changes.

thats it

0
source

I tried everything, as mentioned in the post, and as I found out, my cat used IPv6 instead of IPv4, I also modified this edit /etc/sysctl.conf with the following configuration changes:

net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 

After saving, I ran the command "sudo sysctl -p" to restart sysctl. He changed IPv6 to IPv4 after restarting tomcat. Confirmed

(Before) $ sudo lsof -i: 8080 -n

 COMMAND PID  USER  FD  TYPE DEVICE SIZE/OFF NODE NAME java  4224 tomcat  46u IPv6 15733   0t0 TCP *:webcache (LISTEN) 

(After) $ sudo lsof -i: 8080 -n

 COMMAND PID  USER  FD  TYPE DEVICE SIZE/OFF NODE NAME java  4414 tomcat  46u IPv4 16364   0t0 TCP *:webcache (LISTEN) 

I hope this helps someone encounter a similar problem!

0
source

Adding what is not mentioned in the answers above.

For me, there is no TCP over 8080 . So, I created a new Inbound rule with the following data:

  • Type: Custom TCP Rule
  • Protocol: TCP
  • Port Range: 8080
  • Source: Anywhere

It worked for me. Hope this can help someone. :)

0
source

All Articles