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 '*.facebook.com' 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.

link|improve this question
feedback

2 Answers

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 .hotmail.com

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.

link|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 Jan 4 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 Jan 5 at 9:49
@BahmanMovaqar Great! So far so good. What happens in the squid logs? – Paul Jan 5 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 Jan 5 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 Jan 5 at 16:49
show 2 more comments
feedback

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

link|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 Jan 7 at 6:21
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.