Tech Journal Back to Tech Journal

How do I install auto-proxy configuration on my network? i.e. WPAD (Assuming Apache server)

The following has been customized to match the domain craimer.org, where the name of the proxy server is proxy.craimer.org and the Apache server's IP is 192.168.1.1.

Step 1: Configure DNS

Set DNS for wpad.craimer.org to point to the Apache server using:

wpad  IN  CNAME   spinner

-or-

wpad  IN  A       192.168.1.1

(use the second options if the server doesn't have a name)

Step 2: Create Proxy Auto-Config File

Create a file wpad.dat (and a link from wpad.da [due to a bug in IE]) in the / (root) directory of the server.

The file's format is as follows:

function FindProxyForURL(url, host)
{
        if(shExpMatch(url, "!https:*")
            || isPlainHostName(host)
            || dnsDomainIs(host, ".craimer.org"))
        {
                return "DIRECT";
        }
        else if (url.substring(0, 4) == "ftp:") {
                return "PROXY proxy.craimer.org:8021; DIRECT";
        }
        else if (url.substring(0, 5) == "http:") {
                return "PROXY proxy.craimer.org:8080; DIRECT";
        } else {
                return "DIRECT";
        }
}

That will send all HTTP through a web-proxy on port 8080, all FTP through an FTP-proxy on port 8021 (unless the host is in the local network or is contacted through HTTPS.) All other requests will be done directly.

(Note: maybe using an FTP-proxy isn't always a good idea, since IE's proxy support isn't the best in the world.)

Step 3: Add the MIME-type and Hostname to the Apache Server

Add the MIME type for the auto-config, for .DAT files, by editing the Apache config file:

<VirtualHost 192.168.1.1>
    ServerName wpad.craimer.org
    AddType application/x-ns-proxy-autoconfig .dat
</VirtualHost>

Step 4: Add WPAD entry option to DHCP

Add this line to your /etc/dhcpd.conf:

option option-252               "http://wpad.host.co.nz/proxy.pac";

That doesn't work with DHCPd version 3+, so instead add this line to the global settings

option wpad-url    code 252 = text;

And this line inside the settings for the subnet being served:

option wpad-url    "http://192.168.1.1/wpad.dat\n";
Last updated on 2005-02-17 14:00:00 -0700, by Shalom Craimer

Back to Tech Journal