1 场景
#打包宝塔成docker镜像重启后,宝塔web访问不了,并做了如下的测试都不通,如下:
[root@demo110 dockerbt]# netstat -lantp |grep 8
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4797/nginx: master
tcp 0 0 0.0.0.0:8888 0.0.0.0:* LISTEN 5768/python
[root@prometheus113 ~]# ping 172.16.1.138
PING 172.16.1.138 (172.16.1.138) 56(84) bytes of data.
64 bytes from 172.16.1.138: icmp_seq=1 ttl=64 time=0.853 ms
^C
--- 172.16.1.138 ping statistics ---
[root@prometheus113 ~]# telnet 172.16.1.138 80
Trying 172.16.1.138...
telnet: connect to address 172.16.1.138: No route to host
[root@prometheus113 ~]# telnet 172.16.1.138 8888
Trying 172.16.1.138...
telnet: connect to address 172.16.1.138: No route to host
[root@prometheus113 ~]# curl 172.16.1.138:8888/login
curl: (7) Failed connect to 172.16.1.138:8888; No route to host
2 原因
1 可能是因为写了访问控制规则
2 可能是安装或启用了防火墙
3 nginx配置了安全访问
3 解决方案
#通过命令查看防火墙策略
sudo iptables -L | more
#如果输出内容为Chain INPUT (policy DROP),再执行修改策略
sudo iptables -P INPUT ACCEPT
#直到确认输出为Chain INPUT (policy ACCEPT),才可清除所有规则停止防火墙
sudo iptables -F
#关闭防火墙
systemctl stop firewalld.service