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

We run a few society websites behind a University firewall that mandates that all traffic goes through an internal squid cache / proxy.

While export http_proxy= works perfectly in the shell I'm wondering if there's a similarly easy way to force PHP applications, such as MediaWiki and Wordpress to use and recognise that environment variable. We're running Debian 5.

I found a way to do it once without having to use a local transparent proxy... I just can't remember how.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

This could be achieved through using iptables / netfilter http://www.netfilter.org/

share|improve this answer
    
I've gotten this far: iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j DNAT --to-destination ###.###.###.###:3128 However as soon as that rule is added, the web site falls over as it forwards inbound traffic to the cache. Is there a way to modify that rule so that it only applies to outbound traffic? –  oliland Jun 27 '10 at 18:07

On the router, only allow outgoing port 80 connections (or possibly *all ports) from the squid box (and other whitelisted servers). For preference you might want to think about how to prevent address spoofing (e.g. using IPSEC or a VPN between the whitelisted machines and the router).

C.

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.