Linux – configure Ubuntu to use a proxy for a subset of websites

linuxPROXYUbuntu

I should preface this with stating that I know basically nothing about proxies (despite having written a toy caching proxy a while back :)).

I have a small cluster of servers running behind a firewall. One of these servers ("server0") can be connected to via http on port 8080, the rest are blocked off. I would like to set up a proxy on server0 so that it forwards requests to server1, server2, etc.

I would also like to configure my client machines (all running Ubuntu) to use the proxy on server0:8080 , but only for urls that hit server* , not for the rest of the traffic. So far I've only been able to find instructions for setting up a proxy for all traffic, not just that which matches some regex.

Is this possible? Any hints / links / etc?

Also recommendations on the appropriate choice of proxy software would be great.

Thanks.

Best Answer

Personally I use varnish as a reverse proxy (that I find much more to the task, as opposed as Squid which was not born as a reverse proxy) and it does have advanced feature to redirect traffic to different content backends depending on whatever you want (round robin, regular expressions, load balancing... it's really powerful). If you're interested in it, I can elaborate more on the point.

About the second part of the question (using a proxy only for some addresses) you can use a PAC file as simple as:

function FindProxyForURL(url, host) {
    if (shExpMatch(host, "*.mydomain.com"))
        return "SOCKS 10.0.0.1:1080";
    return "DIRECT";
}
Related Topic