file_get_contents() 仅在 CentOS 安全设置下本地域的安全问题

file_get_contents() security issue on local domain only with CentOS security settings

我知道 SO 上有一百篇关于 file_get_contents() 的帖子,但似乎没有什么能解决我的问题:

15 分钟前一切正常,直到我 运行 通过 SSH 进行了一些安全操作。我添加了一些 iptables 规则,我 file_get_contents 和我 运行 service proftpd restart 和一些 installs/uninstalls 似乎禁用了 PHP 的 fopen() 以某种方式起作用。

在 php.ini 中,我有:allow_url_fopen = on & extension=php_openssl.dll

我正在尝试一个简单的测试:(此文件可以通过浏览器正常加载)

echo file_get_contents("https://www.this-domain.com/logo.gif");
//...failed to open stream:HTTP request failed! HTTP/1.1 404 Not Found...

//However both of the following work absolutely fine:

echo file_get_contents("https://www.google.com/");
echo file_get_contents("/home/user/domains/this-domain.com/private_html/media/logospin.gif");

我无法更改 file_get_contents() 代码(更改为 cURL 或其他方式)- 这是服务器设置问题。可能与防火墙有关。有人可以提出修复建议吗?

问题实际上是 DNS 问题。 file_get_contents() 由于某种原因奇怪地通过我们的备用名称服务器(ns3 和 ns4)进行路由,而浏览器通过主要名称服务器(ns1 和 ns2)进行路由。与主要的不同,备份指向不同的服务器,该服务器还没有相同的文件 - 因此不寻常的 404。

我在修补防火墙等之前仅几个小时就设置了这些备份名称服务器,当它们传播时,看起来很像 ssh 命令已经 file_get_contents() 离线。

感谢大家的评论 - 非常感谢。