There comes a need for many organizations (or individuals) to establish proxy servers on their network. This is usually done for reasons of security or network topology. While the use of proxy servers simpifies some aspects of networking, it comes at the cost of maintaining the browser configuration of every network device (usually browsers). Netscape provided a mechanism to automate much of this problem by allowing the browser to retrieve the proxy configuration from a centrally managed server.
The proxy autoconfig file is written in JavaScript, it should be a separate file that has the proper filename extension and MIME type when provided from a webserver.
The file must define the function:
function FindProxyForURL(url, host)
{
...
}
1. FILENAME EXTENSION:
.pac
2. MIME TYPE:
application/x-ns-proxy-autoconfig
3. REFERENCES:
4. ApacheHTTP config.
Add the following to the httpd.conf file:
Redirect permanent /wpad.dat {yourdomain}/proxy.pac
AddType application/x-ns-proxy-autoconfig .pac
5. EXAMPLE:
/* 'proxy.pac' - This is the main function called by any browser */
function FindProxyForURL(url, host)
{
if (isPlainHostName(host) || // No Proxy for Non FQDN names
shExpMatch(host, “*.localnet”) || // No Proxy for internal network
shExpMatch(host, “127.0.0.1”) || // No Proxy for LocalHost
shExpMatch(host, “localhost”) || // No Proxy for LocalHost
shExpMatch(host, “mailhost”) || // No Proxy for MailHost
dnsDomainIs(host, “giantgeek.com”) || // No Proxy
return “DIRECT”;
else {
return “PROXY proxy.giantgeek.com:8080; PROXY proxy.giantgeek.com:8090; PROXY proxy2.giantgeek.com:8080”;
} //End else
} // End function FindProxyForUrl
NOTE: Also see my ‘WPAD’ blog entry.