Web Proxy Auto Detect (WPAD)

Internet Explorer (>4 w/ DHCP), Firefox, Safari and Google Chrome all support WPAD. WPAD requires a proxy auto-configuration (PAC) file (named "wpad.dat") which defines the appropiate proxy settings and WPAD tells the browser how to find the PAC file via DHCP or DNS. Any URL for the DHCP protocol.
function FindProxyForURL(url, host) {

// If IP address is internal or hostname resolves to internal IP, send direct.

	var resolved_ip = dnsResolve(host);

	if (isInNet(resolved_ip, "10.0.0.0", "255.0.0.0") ||
		isInNet(resolved_ip, "172.16.0.0",  "255.240.0.0") ||
		isInNet(resolved_ip, "192.168.0.0", "255.255.0.0") ||
		isInNet(resolved_ip, "127.0.0.0", "255.255.255.0"))
		return "DIRECT";
	
// Use a different proxy for each protocol.	
      if (shExpMatch(url, "http:*"))  return "PROXY proxy1.domain.com:3128";
      if (shExpMatch(url, "https:*")) return "PROXY proxy2.domain.com:3128";
      if (shExpMatch(url, "ftp:*")) return "PROXY proxy3.domain.com:3128";
 
}

Firefox

Settings are kept in "prefs.js" in "%APPDATA%\Mozilla\" or in "all.js" in "%PROGRAMFILES%\Mozilla Firefox\greprefs" up to Firefox 2.x. In Firefox 3 they've been moved to a sqlite database in "%USERPROFILE%\Local Settings\Application Data\Mozilla\Firefox\Profiles\xxxxxxxx.default"
	  all.js
          pref("network.proxy.type", "0");
	  pref("network.proxy.ftp", "proxy");
	  pref("network.proxy.ftp_port", 3128);
	  pref("network.proxy.http", "proxy");
	  pref("network.proxy.http_port", 3128);
	  pref("network.proxy.ssl", "proxy");
	  pref("network.proxy.ssl_port", 3128);
	  pref("network.proxy.type", 1);

pref("network.proxy.type", "0"); where 0 = direct, 1 = manual, 2 = PAC, 3 -> mapped to 0, 4 = Auto-detect proxy settings for this network. Only this line needs to be updated to configure for autodetect.

Internet Explorer

In an AD domain group policies can be used: User Configuration > Windows Settings > Internet Explore Maintenance > Connection > Proxy Settings.

Web Proxy Auto Detect (WPAD) - For Internet Explorer,

You could also use the group policy editor:
  1. On the Domain Controller machine click on Start and select Run.
  2. Type gpedit.msc in the Open field to open Group Policy.
  3. Navigate to Computer Configuration\Administrative Templates\Windows Components\Internet Explorer.
  4. Enable the policy: Disable changing proxy settings Properties. Click OK.
  5. Navigate within the Group Policy to Configuration\Windows Settings\Internet Explorer Maintenance\Connection.
  6. Right click on Proxy Settings and select Properties.
  7. Check the Enable proxy settings box. Enter the IP address of your proxy server in the HTTP field. Click OK.

Or edit the registry with a logon script:

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /t REG_SZ /d "192.168.168.5:3128" /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOveride /t REG_SZ /d "<local>" /f

You can also create an registy file and import it using regedit in the logon script with "Regedit /s z:\public\setproxy.reg" where z:\public\setproxy.reg is the correct path for your network. The registry file can be created in notepad and should contain the following:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"ProxyServer"="192.168.168.5:3128"
"ProxyEnable"=dword:00000001
"ProxyOverride"="<local>"

Where 192.168.168.5:3128 is the actual IP adress and port number of your proxy server.


Handwritten notes:
DHCP SERVER
  1. WPAD DNS ENTRY

    Create a wpad CNAME for an internal webserver. This is the default location that most browsers when set to "autodetect" will go.

  2. CREATE WPAD FILE
    ...and save as "wpad.dat" on the root of the webserver.
          function FindProxyForURL(url, host)
          {
           if (isInNet(myIpAddress(), "192.168.168.0", "255.255.255.0"))
            return "PROXY 192.168.168.5:3128";
           else
            return "DIRECT";
          }

    You'll have to add the MIME type for the wpad.dat file

    On IIS: Internet Information Services > Expand until you get to the domain name. right-click on the domain name and select Properties > HTTP Headers > MIME Types > New

    Extension: .dat
    MIME type: application/x-ns-proxy-autoconfig

    On Apache: Create a .htacces file in the same directory as the wpad.dat file that reads:

    AddType application/x-ns-proxy-autoconfig .dat
  3. ADD WPAD ENTRY TO WINDOWS 2003 DHCP SERVER
    DHCP Option 252 entry w/ string value indicating the URL of the WPAD server
    Start > Programs > Administrative Tools > DHCP > right-click on DHCP Server and select Set Predefined Options > Add.

    Name: WPAD
    Data Type: String > OK
    Code: 252
    String: http://wpad.company.com/wpad.dat - "wpad.dat" must be lowercase. Should the "http://" be there?

    Right click on Server Options > Configure Options. Confirm that Option 252 is checked.

  4. CONFIGURE WPAD FOR DHCP SCOPE
    ... > Administrative Tools > DHCP > right-click Scope Options > Configure Options > Advanced > Vendor Class > Standard Options > in Available Options select 252 Proxy Autodiscovery checkbox and click OK.