在配置好服務器之後,訪問公網IP,結果一直顯示此頁面:
當tomcat啓動成功後,訪問web服務器,請求失敗。導致失敗的原因之一可能就是防火牆將8080端口或者其他端口攔截掉了,我們需要重新開放8080或者其他端口,不建議關閉防火牆。
CentOS7之後,防火牆從iptables變成了firewalld。
若tomcat防火牆和啓動正常,仍無法訪問tomcat,那你就要去看一下安全組的設置
firewalld防火牆基本操作:
1.查看防火牆狀態:
systemctl status firewalld或者 firewall-cmd --state
2.查看開放端口列表
firewall-cmd --list-ports
3.在指定區域打開端口(記得重啓防火牆)(永久生效再加上 --permanent)
firewall-cmd --zone=public --add-port=8080/tcp
4.啓動防火牆
systemctl start firewalld
5.禁用防火牆
systemctl stop firewalld
6.設置開機啓動
systemctl enable firewalld
7.停止並禁用開機啓動
sytemctl disable firewalld
8.重啓防火牆
firewall-cmd --reload
9.查看版本
firewall-cmd --version
10.查看幫助
firewall-cmd --help