I'm developing a php application. I'm using wamp and I'm behind a corporate proxy. I'm using cntlm to authenticate NTLM. I need to curl google geocoding api, in order to do this I used the following settings that are working:
curl_setopt($ch,CURLOPT_PROXY, '127.0.0.1:3128');
curl_setopt($ch, CURLOPT_PROXYPORT, 3128);
I'd like to find a way to avoid setting those options for CURL. I believe I can play with Apache setting, but I'm not sure. The reasons I need to find this solution are:
- In production env there will be no such a proxy (at the moment the above options are used only if the environment variable is set to DEV env, but still: it's not the best solution)
- If I want to use 3rd party SDK (such as facebook php sdk), those are internally using CURL but they do not necessarily expose method to change CURL options (for example facebook sdk doesn't). I don't want to change the SDK source code to fit my proxy
What I tried:
So far I turned on proxy_module on apache and I added the following line on httpd.conf, but with no success
ProxyRemote * http://127.0.0.1:3128
I still can't access the internet. I googled a lot, but I couldn't find a solution, any ideas?
I could find many people talking about the same issue, but I didn't find any comprehensive solution, for this reason I raise a bounty.
What I found:
There is this bug in which I found: But I'm not sure if this will work for curl and anyway I can't find how to modify the php.ini
[2010-12-20 14:03 UTC] jani@php.net -Summary: changing the default http-wrapper +Summary: Add php.ini option to set default proxy for wrappers -Package: Feature/Change Request +Package: Streams related -PHP Version: 5CVS +PHP Version: *
and
[2011-04-05 11:29 UTC] play4fun_82 at yahoo dot com Hi, i have the same problem. My solution was to pass through proxy server with cntml tunneling tool. You configure cntml proxy to forward http request received on local host on a port to destination with proper authentication.
And in pear u just configure
pear config-set http_proxy 127.0.0.1:3128
3128 - is port configuret in cntlm(it can be any other free port).
Thanks very much