Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache behind corporate proxy

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:

  1. 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)
  2. 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] [email protected] -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

like image 398
Stefano Giacone Avatar asked Sep 28 '15 11:09

Stefano Giacone


People also ask

Does Apache act as a proxy server?

In addition to being a "basic" web server, and providing static and dynamic content to end-users, Apache httpd (as well as most other web servers) can also act as a reverse proxy server, also-known-as a "gateway" server.

What is proxy in Apache?

An ordinary forward proxy is an intermediate server that sits between the client and the origin server. In order to get content from the origin server, the client sends a request to the proxy naming the origin server as the target. The proxy then requests the content from the origin server and returns it to the client.

What is proxy timeout in Apache?

Apache Default timeout is set to 300 seconds. This issue comes only when accessing website through apache reverse proxy. It works well by using internal IP.


1 Answers

You're saying you want this functionality on WAMP, for your development computer only, right? The SDK's work without modification in production, so you can just take advantage of your Window's Host file to redirect requests.

Here's a walkthrough.

like image 162
I wrestled a bear once. Avatar answered Oct 13 '22 06:10

I wrestled a bear once.