Howtos / Articles

Advanced .PAC proxy auto config file example

The following example pac proxy auto config file will allow you to bypass the proxy server for all local IP addresses, and also set exclusions on specific domain names.


For information on what a PAC file is, please check out:


What is a .pac proxy auto config file



Advanced .PAC proxy auto config file example:


function FindProxyForURL(url, host) {

    var ProxyServer     = "PROXY; DIRECT"; //Proxy server to use for HTTP/HTTPS.
    //var ProxyServer     = "PROXY"; //Use this if you want to prevent falling back to "DIRECT" if the proxy isnt accessible.

    var FTPProxy        = "DIRECT";    //Proxy server to use for FTP (No proxy in this example)
    var LocalSubnet     = "";   //The network address for your local IP
    var LocalSubnetMask = ";    //Subnet mask for your local network

    //set up a list of urls you want direct access to. you can use regular expressions.
    var DirectHosts = [

    //Checks if the request is for a FTP site. Use the FTPProxy setting if so.
    if (url.substring(0,3)=="ftp") {
        return FTPProxy;

    //Checks to see if the IP address is on the local subnet, 
    if (isInNet(dnsResolve(host), LocalSubnet, LocalSubnetMask)) {
        return "DIRECT";

    //Checks if there are no dots in the hostname. (indicating a site on a local LAN)
    if (isPlainHostName(host)) {
        return "DIRECT";

    //Check all the enteries in the DirectHosts array.
    for (var i in DirectHosts) {
        if (shExpMatch(host, DirectHosts[i])) {
            return "DIRECT";

    //use the default proxy specified at the top as ProxyServer.
    return ProxyServer;

Share this howto article!
  • Facebook
  • Twitter
  • Reddit
  • email

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>