Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 2 down vote accepted

This could be achieved through using iptables / netfilter

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).


share|improve this answer

Your Answer


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.