Cannot access tomcat instance installed in EC2

六眼飞鱼酱① 提交于 2019-12-05 09:52:17

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

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.

shivaghaneesh

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!