Firefox – how to set an inclusive proxy list instead of a exclusive one for firefox

firefoxPROXY

Normally firefox and other browsers allow users to set an exclusive list in which proxy won't apply to the specified domain names or ip addresses? My question is that how to do it other way around to specify only the domains to let the proxy to apply to?

Best Answer

If you want to configure the browsers of multiple machines in a standard way, just about all popular browsers support the proxy auto-config file. This allows you to have an arbitrarily complex set of rules for whether to use a proxy and which one to use, and means you solve the problem for all popular browsers.

An example proxy.pac that could meet your described requirements:

// proxy.pac: Proxy Auto-Configuration file.

function FindProxyForURL( url, host ) {

    var proxy_spec = "proxy.localnet:3128";

    // Default to using no proxy.
    var ProxyConfig = "DIRECT";

    if(
        dnsDomainIs( host, ".foo.example.org" ) ||
        dnsDomainIs( host, ".bar.example.com" ) ||
        dnsDomainIs( host, ".baz.example.net" )
    ) {
        // Requested domain matches, let's use the proxy.
        ProxyConfig = "PROXY " + proxy_spec;
    } // end if

    return ProxyConfig;

} // end FindProxyForURL()