Ok, I have two Linux boxes running behind a proxy server. Both boxes are set to bypass the filtering by connecting on port 801.
Box A – Fedora Core 12 / PHP 5.3.1
Box B – RHEL 6 / PHP 5.3.3
On Box A I am able to use file_get_contents() to conenct to an external site.
<?php
$opts = array(
'http' => array(
'proxy' => 'tcp://10.136.132.1:801',
'request_fulluri' => true
)
);
$cxContext = stream_context_set_default($opts);
echo file_get_contents("http://www.google.com");
This results in Google’s homepage being displayed.
On Box B I run the same code, but get this error:
Warning: file_get_contents(http://www.google.com): failed to open stream: Permission denied
Both boxes are on the same network and behind the same proxy server. Is there a setting I am missing in Apache or PHP that will allow file_get_contents to work on Box B?
It sounds like you have SELinux enabled, it blocks any outgoing connections by Apache by default. Try running this in your shell as root:
More info on SELinux booleans can be found here:
http://wiki.centos.org/TipsAndTricks/SelinuxBooleans