Skip to main content
2 of 2
replaced http://serverfault.com/ with https://serverfault.com/

Most browsers that support Javascript also support Netscape-style proxy autoconfiguration (PAC) files (I'm not aware of a JavaScript-capable browser released this century that doesn't). PAC files contain JavaScript code that is executed to determine what proxy (if any) to use for each request.

function FindProxyForURL(url, host) {
    if (shExpMatch(host, "*.example.com")) {
        return "DIRECT";
    } else if (shExpMatch(host, "somewhere.else")) {
        return "PROXY someproxy:8080";
    } else {
        return "PROXY default-proxy.example.com:3128";
    }
}

To have a single setting for browsers and other applications that don't support Javascript, you'll need a proxy that supports per-URL parent proxies.

Squid is one possibility, it's a caching proxy designed for high loads and with many features. See Squid selects parent depending on requested URL? for examples of how to set up per-URL parent proxies.

Wwwoffle is another possibility. This proxy is strongly oriented towards having an offline cache, and caches more aggressively than is allowed by the HTTP standards, which is a problem with some sites. Parent proxies can be specified per-URL with wildcard patterns (the default configuration files contains commented-out examples).

Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k