Web Hosting Talk







View Full Version : Strange file() issue - PHP


ScottAN
04-01-2008, 04:56 PM
So I am trying to resolve an issue with my companies server status script that we use to monitor a number of servers. It checks using cron and gets the load averages for each server by using the file() command to access a server side php file that reports the load avg. ANYWAY.. I'm getting this error when accessing ONLY ONE of the servers:

PHP Warning: file(http://IPADDRESS:80/server_script.php): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found

Out of ~30 servers only one is causing this error. I've checked the firewall on the server causing the error and thats not the issue. I've flushed DNS on the checking server and the server causing the error. Even stranger, using

wget http://IPADDRESS:80/server_script.php

through the shell works just fine. Has anyone experienced anything like this??

funkytaco
04-01-2008, 05:52 PM
Maybe there is a hidden character in your code for that URL? You can always try fopen, as that is meant to be used for URL's.

http://us3.php.net/fopen

If you are actually copying the file the copy() function might be easiest of all.

http://us.php.net/copy

$file = 'http://IPADDRESS:80/server_script.php';
$newfile = '/local/path/to/server_script.php';

if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
}

Adam-AEC
04-02-2008, 01:15 PM
Did you check the httpd logs on the server?

Possible a mod_sec rule denying the request because of the User-Agent header?

ScottAN
04-02-2008, 05:15 PM
Issue is not resolved, thanks for the suggestions.

Adam-AEC-
It did turn out to be a misconfiguration in httpd.conf file (a mod_security rule).