A proxy.pac is a script that you can use to create rules for dynamically assigning proxy names. With it, you can get more flexible with your proxy setups. For example, you can set your PCs to not go through the proxy server if the URL being browsed is an Intranet page. Below is an example entry to a proxy.pac file that will handle that scenario:
function FindProxyForURL(url, host)
{
if (dnsDomainIs(host, "your_local_domain.com"))
{
return "DIRECT";
}
return “PROXY your_web_proxy:XXXX”;
}As you can see the script is easy to read if you have been working with regular scripts like Java Script. The proxy.pac needs to have function FindProxyForURL(url, host) as its main function. It takes two parameters: url and host so you can create conditions depending on the url and host.
The example I have above should be customized on the part where it says “your_local_domain.com”. For example, if you work inside ACME.com, change “your_local_domain.com” to “ACME.com”. This makes sense since a proxy server typically does not have to be used if you don’t have to go outside the local network.
If you have many proxy servers you can add more if and then conditions to handle more complex rules. Below is an example from wiki’s entry to proxy.pac:
function FindProxyForURL(url, host) {
// our local URLs from the domains below example.com don't need a proxy:
if (shExpMatch(url,"*.example.com/*")) {return "DIRECT";}
if (shExpMatch(url, "*.example.com:*/*")) {return "DIRECT";}
// URLs within this network are accessed through
// port 8080 on fastproxy.example.com:
if (isInNet(host, "10.0.0.0", "255.255.248.0")) {
return "PROXY fastproxy.example.com:8080";
}
// All other requests go through port 8080 of proxy.example.com.
// should that fail to respond, go directly to the WWW:
return "PROXY proxy.example.com:8080; DIRECT";
}Network administrators should utilize proxy.pac to automatically manage their outgoing web traffic. To use a proxy.pac file, just put it in the network setting of your web browser:
It could be located on a web server or locally on your hard disk. On the next post we will look at automatically detecting proxy settings using WPAD.
Ben Carigtan shows you how it’s done.












Hi Ben, is this applicable to ISA servers?