Configure Apache to use external proxy for internet connection
In my application I am using following rewrite rule:
RewriteRule ^/ajax(.*) http://api.externalserver.com/$1 [P,QSA,L]
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?
I think you'll want to enable mod_proxy_http
, and set:
ProxyRemote * http://11.22.11.22:8585
somewhere in your virtualhost configuration.
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
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/
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