Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

In my application I am using following rewrite rule:

RewriteRule ^/ajax(.*) http://api.externalserver.com/$1 [P,QSA,L]

You know what it does.

Now the problem is that my corporate network requires me to use HTTP proxy for external internet connections.

To ilustrate, this doesn't work:

curl -v http://api.externalserver.com/login

But this works:

curl -v -x 11.22.11.22:8585 http://api.externalserver.com/login

How can I make Apache use the corporate proxy for external internet requests?

share|improve this question

5 Answers 5

up vote 6 down vote accepted
+50

I think you'll want to enable mod_proxy_http, and set:

ProxyRemote * http://11.22.11.22:8585

somewhere in your virtualhost configuration.

share|improve this answer

Did you try http tunneling, via proxytunnel or corkscrew ?

You need to configure a vhost for your Apache and use it as a distant proxy.

Maybe adapting this could help you : http://dag.wieers.com/howto/ssh-http-tunneling/

share|improve this answer

I think what you are looking for is mod_proxy, and mod_proxy_http specifically:

http://httpd.apache.org/docs/2.2/mod/mod_proxy_http.html

share|improve this answer

You may install SQUID proxy in transparent mode to proxy all traffic going from local machine to the internet.

For this first add iptables rule

iptables -t nat -A OUTPUT -p tcp --dport 5555 -j DNAT --to 127.0.0.1:3128

this will redirect all outgoing http connections to local squid. Then configure squid according to this guide and additionaly configure

cache_peer 11.22.11.22 parent 8585 0 no-query default
never_direct allow all

That's all. All your outgoing traffic to port 80 will go through your organisation proxy

share|improve this answer

After setting ProxyRemote and restarted httpd, if you got the "[error] (13)Permission denied: proxy: HTTP: attempt to connect to failed", then you also need to execute the following:

setsebool -P httpd_can_network_connect=1
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["                  <li><a href=\"//area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"//careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2015 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2015.4.27.2529\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Server Fault works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </noscr"], "copyright__copyright__copyright": ["gh your organisation proxy\n\nshare|improve this answer\n\nAfter setting ProxyRemote and restarted httpd, if you got the \"[error] (13)Permission denied: proxy: HTTP: attempt to connect to failed\", then you also need to execute the following:\n\nsetsebool -P httpd_can_network_connect=1\nshare|improve this answer\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}