Guide

Deploy Squid proxy settings to Windows clients with Group Policy and WPAD

A Squid proxy on Windows Server does nothing until clients use it. On a Windows domain you set that once, centrally: a fixed proxy by Group Policy, a PAC file that decides per address, or automatic discovery with WPAD. This guide covers each, the WinHTTP setting that services use, and what domain sign-on needs.

Which method to use

  • Group Policy with a fixed proxy is the simplest: every user gets the proxy's name and port, plus a list of addresses that go direct.
  • Group Policy with a PAC file puts the rules in one file on a web server: which addresses go direct, which go through the proxy, and what to do if it does not answer. Change the file and every client follows.
  • WPAD lets clients find the PAC file themselves through DNS or DHCP. It reaches computers outside Group Policy, but any device that can answer for the name wpad on your network can hand clients a proxy of its choosing. Use it only when Group Policy cannot reach the computers.

Whichever you choose, Windows has two proxy settings: the user setting, used by Edge, Chrome, Office and most programs, and the WinHTTP setting, used by many services. The first three methods set the user setting; WinHTTP is separate.

Group Policy: the Internet Settings preference

The proxy setting is deployed with a Group Policy preference. Despite its name, the Internet Explorer 10 item sets the Windows proxy setting that current browsers and programs read.

  1. In Group Policy Management, create a GPO and link it to the organizational unit that holds your users, or edit an existing one.
  2. Go to User Configuration → Preferences → Control Panel Settings → Internet Settings, right-click, and choose New → Internet Explorer 10.
  3. On the Connections tab, choose LAN settings. Either tick Use a proxy server for your LAN and enter the proxy's DNS name and port (for example proxy.example.local and 3128), with Bypass proxy server for local addresses ticked; or tick Use automatic configuration script and enter the PAC file's address (below).
  4. For a fixed proxy, add the addresses that should go direct under Advanced → Exceptions, separated by semicolons, for example *.example.local;10.*;192.168.*.
  5. A setting in the preference is applied only when it is underlined in green; a red dashed underline means it is left alone. Press F5 to enable every setting on the current tab, or F6 for the selected one (F7 and F8 disable).

Clients pick it up at their next policy refresh; gpupdate /force on a client applies it at once. To stop users changing it, enable Prevent changing proxy settings under User Configuration → Policies → Administrative Templates → Windows Components → Internet Explorer.

A PAC file

A PAC (proxy auto-config) file is a short JavaScript function that browsers and Windows call for every address. This one sends internal names and internal IP addresses direct and everything else to Squid:

function FindProxyForURL(url, host) {
  // Names without a dot, and your internal domain, go direct.
  if (isPlainHostName(host) || dnsDomainIs(host, ".example.local"))
    return "DIRECT";

  // Private IP addresses typed as numbers go direct.
  if (/^\d+\.\d+\.\d+\.\d+$/.test(host) &&
      (isInNet(host, "10.0.0.0", "255.0.0.0") ||
       isInNet(host, "172.16.0.0", "255.240.0.0") ||
       isInNet(host, "192.168.0.0", "255.255.0.0") ||
       isInNet(host, "127.0.0.0", "255.0.0.0")))
    return "DIRECT";

  // Everything else through Squid; if it does not answer, go direct.
  return "PROXY proxy.example.local:3128; DIRECT";
}
  • The IP checks run only for addresses typed as numbers, so the file never makes a DNS lookup of its own.
  • ; DIRECT at the end lets users keep browsing when the proxy is down. If all web traffic must pass through the proxy, for filtering or logging, leave it out.
  • Name the proxy by its DNS name, not its IP address, if you use domain sign-on (below).

Serving it from IIS. Save the file on an internal web server, for example as proxy.pac, and serve it with the type application/x-ns-proxy-autoconfig. IIS serves no file whose extension it has no type for, so add one with a web.config in the same folder. For WPAD, the same file is also served as wpad.dat:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <staticContent>
      <remove fileExtension=".pac" />
      <mimeMap fileExtension=".pac" mimeType="application/x-ns-proxy-autoconfig" />
      <remove fileExtension=".dat" />
      <mimeMap fileExtension=".dat" mimeType="application/x-ns-proxy-autoconfig" />
    </staticContent>
  </system.webServer>
</configuration>

Then enter its address, for example http://proxy.example.local/proxy.pac, as the automatic configuration script in the Group Policy preference above. Clients keep a copy of the file for a while, so test a change on one computer before relying on it everywhere.

WPAD: discovery through DNS and DHCP

With Automatically detect settings on, which is the Windows default, a client looks for a PAC file without being told where it is. It asks DHCP for option 252, and it looks up the DNS name wpad in its own domain and fetches http://wpad.example.local/wpad.dat.

DNS. Create a host record named wpad in your internal zone that points at the web server holding wpad.dat, and serve the file at the root of a site that answers for that name over plain HTTP on port 80. Windows DNS Server does not answer queries for wpad by default: the name is on its global query block list, as a defense against WPAD spoofing. To allow it, run this on each DNS server, which leaves isatap on the list and takes wpad off:

dnscmd /config /globalqueryblocklist isatap

or, in PowerShell:

Set-DnsServerGlobalQueryBlockList -List isatap

DHCP. On a Windows DHCP server, define option 252 once, then set it on the scopes your clients use:

Add-DhcpServerv4OptionDefinition -OptionId 252 -Name WPAD -Type String
Set-DhcpServerv4OptionValue -ScopeId 10.0.0.0 -OptionId 252 `
  -Value "http://wpad.example.local/wpad.dat"

DHCP discovery reaches only clients that ask for the option; browsers that do their own discovery may use DNS alone. Setting up both is the usual approach.

WinHTTP: the proxy setting for services

Windows services and background agents that use WinHTTP do not read the user setting. They have their own, set per computer from an elevated prompt:

netsh winhttp set proxy proxy-server="proxy.example.local:3128" bypass-list="*.example.local;<local>"
netsh winhttp show proxy
netsh winhttp reset proxy

netsh winhttp import proxy source=ie copies the signed-in user's fixed proxy setting instead; it does not copy a PAC file address. To set WinHTTP on many computers, run the set proxy command from a computer startup script in a GPO.

Domain sign-on through the proxy

When the proxy requires Windows domain sign-on, domain computers sign in without asking the user, but only when they reach the proxy the right way:

  • Use the proxy's DNS name everywhere: in the Group Policy preference, the PAC file and WinHTTP. With the name, sign-on can use Kerberos; with an IP address it falls back to NTLM.
  • Use the server's own name, or register the alias. If clients reach the proxy through an alias (a CNAME such as proxy.example.local for the server SRV-PROXY01), Kerberos may need a service principal name for the alias on the server's computer account: setspn -S HTTP/proxy.example.local SRV-PROXY01.
  • Put the proxy in the Local intranet zone if browsers show a password prompt anyway. Deploy it with Site to Zone Assignment List under Administrative Templates → Windows Components → Internet Explorer → Internet Control Panel → Security Page, with the proxy's name and the value 1.

Squid Proxy Professional sets up sign-on with one setting; see Windows domain sign-on in the documentation.

Checking a client

  • Settings → Network & Internet → Proxy on the client shows the setting it received; a setting deployed by policy appears there.
  • netsh winhttp show proxy shows the WinHTTP setting.
  • Browse to an outside site, then look for the client's address in Squid's access.log. In Squid Proxy Professional, the console's Logs page follows it live.
  • Programs that ignore the Windows setting need their own: command-line tools such as curl and git, Java applications, and Firefox when it has been changed from Use system proxy settings.

The install guide covers testing the proxy itself, and the documentation opening its port in Windows Firewall.

Try it

A Squid proxy for your Windows domain.

The 30-day evaluation is the full product, and starts on activation.