Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Internet censorship -where I live- has almost turned web unusable so I decided to setup a transparent proxy using Tor for my home network. ince Tor is so slow -here- proxying all traffic through Tor would slow my connection to a crawl. Therefore I need a mechanism to selectively proxy the traffic.

I know a bit of 'iptables' and it looks to me like the solution to my problem. However there's a trick. As most of the websites I need to access through Tor (like Google+, Facebook and such) use several IP addresses for their entry points, it's almost impossible for me to add 'iptables' rules for all of those IP addresses. I need a mechanism to proxy the traffic based on URL patterns. For example I need to be able to proxy access to '*' through Tor.

So the question boils down to: how can I setup a system-wide transparent proxy using URL patterns?

Any idea/hint is much appreciated.

share|improve this question

Squid might be what you want.

Squid out of the box configuration is generally ready to go as a proxy server, so the next thing you would need is an ACL like:

acl viator dstdomain

So here you would include all the domains you want to proxy.

And you'll want the tor proxy defined:

cache_peer tor.proxy     parent    <tor port>       0

Then a command to direct traffic to tor, and prevent direct access for those domains, then let everything else through:

cache_peer_access tor.proxy allow viator
never_direct allow viator
always_direct allow !viator

Deployment of squid in your environment would require more information about your setup.

share|improve this answer
Thanks...I'll give this approach a try. My installation is a vanilla 64bit ArchLinux. Just one question: If I get Squid to work, will it operate as a transparent proxy or I should set the proxy in any program I'm using? – Bahman M. Jan 4 '12 at 9:06
UPDATE: I got Squid + iptables working as a transproxy. Now the only obstacle is making Squid use Tor. The lines you provided are not working -perhaps I'm doing something wrong. – Bahman M. Jan 5 '12 at 9:49
@BahmanMovaqar Great! So far so good. What happens in the squid logs? – Paul Jan 5 '12 at 12:49
Actually there isn't anything neither in access.log nor in cache.log that indicates anything has connected to squid unless I use squidclient; I'm just judging based on the blazing fast speed of page reloads after squid was setup :-) Perhaps would be nice if you could please help me find a way to make sure squid is working -other than hunch :-) TIA, – Bahman M. Jan 5 '12 at 15:58
I found out how to increase the log level of squid. So here is the squid.conf and this is the resulting cache.log. – Bahman M. Jan 5 '12 at 16:49

You don't have to install and use an additional proxy server, of course.

Selecting a HTTP proxy server according to the pattern of the URL is exactly what proxy-auto-configuration scripts do, after all.

Further reading

share|improve this answer
Thanks but I need a system-wide transparent proxy which applies to any program using the internet not just only the browser. – Bahman M. Jan 7 '12 at 6:21

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.