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服务即可正常访问

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容