centos7防火墙

按照往常,配置好nginx,成功启动nginx,但是外网无法访问,域名,ip都不通。排查半天才发现是防火墙的问题。

下面说说遇到这种情况,一般的排查思路:

  • 首先ping 你的域名,看域名解析是否正确
  • nginx -t 看下配置是否有问题
  • php-fpm 是否启动

如果以上都没有问题,看下80端口是否开放
netstat -ntlp

端口正常

既然外网访问不了

内网 curl 访问试试,如果内网可行 外网访问不了,那差不多就应该是防火墙问题了
ps -ef|grep iptables
/etc/init.d/iptables stop
如果出现以下信息:
Failed to stop iptables.service: Unit iptables.service not loaded.

centos从7开始默认用的是firewalld,这个是基于iptables的,虽然有iptables的核心,但是iptables的服务是没安装的。
所以你只要停止firewalld服务即可:
sudo systemctl stop firewalld.service && sudo systemctl disable firewalld.service

如果你要改用iptables的话,需要安装iptables服务:
sudo yum install iptables-services
sudo systemctl enable iptables && sudo systemctl enable ip6tables
sudo systemctl start iptables && sudo systemctl start ip6tables

以上nginx服务即可正常访问

你可能感兴趣的:(centos7防火墙)