4

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 set a proxy to apache/php.

How to configure an apache server to proxy for all outgoing connections ?

2 Answers 2

3

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...

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you, if I correctly understand there is no way to do this from apache or php configuration file ?
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 ?
i would suggest using wireshark or logging the requests on the target server
try charlesproxy.com and see this tutorial for example for SOAP artur.ejsmont.org/blog/content/…
0

use nginx server along with Apache. it is a reverse proxy server..it can be configured to handle html requests by itself and send php requests to Apache(Apache must be listening on localhost)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.