Cannot access tomcat instance installed in EC2

放肆的年华 提交于 2020-01-02 04:15:19

问题


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.

Any help on this would be really appreciated.


回答1:


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



回答2:


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




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/21966082/cannot-access-tomcat-instance-installed-in-ec2

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