views:

19

answers:

1

Hi,

I have local apache server, and I need to pass all requests from php script (running on my local server) through a proxy. So I need to se a proxy to apache/php.

Is it doable ? Can somebody tell me how ?

Thanks.

A: 

well the answer is partly yes. php has socket opening functions, so you theoretically can do everything by defining your own functions. but php has introduced the context parameter into most of the functions that do external calls. an example usage for file_get_contents would be the following:

 $url = 'http://www';

 $proxy = 'tcp://xxx:8080';

 $context = array(
    'http' => array(
        'proxy' => $proxy,
        'request_fulluri' => True,
        ),
    );

 $context = stream_context_create($context);

 $body = file_get_contents($url, False, $context);

but you cannot do "something" to make all your requests magically go through a proxy. well this is not entirely true as well, but you have to do it on another layer. you have the possibility to use a VPN which will work great as it emulates a network card. there are also utilities to do the same for socks proxies, i also heard for some hacks to port something through http proxies but i think its rather unlikely that they work properly...

Joe Hopfgartner
Thank you, if I correctly understand there is no way to do this from apache or php configuration file ?
Ionica
More exactly, I need to use Fiddler, to see the requests from a php script. This is why I need to set the proxy there. Do you have any other solution for this ?
Ionica
i would suggest using wireshark or logging the requests on the target server
Joe Hopfgartner