2015-07-10 55 views
0

我知道有一百个职位约file_get_contents()对SO,但似乎没有解决我的问题:file_get_contents()函数安全问题只能用CentOS的安全设置

一切工作正常15分钟前,直到我跑一些安全的东西通过SSH。我添加了一些iptables规则和我file_get_contents,我跑service proftpd restart和一些安装/卸载似乎已禁用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或其他方式) - 这是一个服务器设置问题。可能与防火墙有关。有人可以请建议修复吗?

+4

404不是php的问题。你的网址不正确,或者请求打错了网站。 –

+0

我没有改变代码 - 我只是运行一些SSH命令来更新安全 – cronoklee

+4

好吧,我没有看到重新启动FTP服务器将如何影响在Apache内运行的PHP ... –

回答

0

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

我已经设置了这些备份域名服务器只有几个小时之前修改防火墙等,并在时间他们传播,它看起来非常像ssh命令离线采取file_get_contents()

感谢所有评论家伙 - 非常感谢。

+0

任何想法为什么'file_get_contents'会通过不同的名称服务器路由到浏览器? – cronoklee