Question

I have install tomcat 7 in an Ubuntu EC2 instance. It's up and running but I cannot access it using the public ip (54.213.225.148:8080). I have also setup the security groups as specified in the previous posts. But, still no luck.

security groups setup

Any help on this would be really appreciated.

Was it helpful?

Solution

Make sure your Ubuntu Uncomplicated Firewall is controlling the traffic instead of iptables.

sudo ufw enable

Then to configure it to allow 8080.

sudo ufw allow 8080

OTHER TIPS

You should Add the port number to the firewall setting in the system also.

sudo iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

where 8080 is the tomcat port number.

On Ubuntu 14.04 in EC2

#to save the rules you have created and to load them when the server starts.
sudo apt-get install iptables-persistent
sudo service iptables-persistent start

#the rule that explicitly accepts your current SSH connection
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
#block all incoming traffic, except for those: 22 for SSH and 80 for web traffic
sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
#block the remaining traffic
sudo iptables -A INPUT -j DROP
#allow loopback access
sudo iptables -I INPUT 1 -i lo -j ACCEPT
#save changes
sudo /etc/init.d/iptables-persistent save

#allow port 8080
sudo iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT
sudo /etc/init.d/iptables-persistent save

more on iptables on Ubuntu

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-ip-tables-on-ubuntu-12-04 https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-iptables-on-ubuntu-14-04

Just by enabling HTTP/HTTPS will not work. You need to enable TCP port too.

Also it need not be just public ip, you can access tomcat even if it is in your VPC using private IP address.

In Windows Server 2016

  1. On AWS -> Security Group for EC2 enable:

    • Inbound Rules (All trafic - Anywhere)
    • Outbound Rules (All trafic - Anywhere)
  2. On Remote EC2 open -> "Windows firewall with Anvanced Security" and open

    • Inbound (All ports)
    • Outbound (All ports)

Thats work for me.

PD: be care this configuration is very insecure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top