Oct 10, 2017

Example of a PAC file

A very simple example of a PAC file is:
function FindProxyForURL(url, host)
{
 return "PROXY proxy.example.com:8080; DIRECT";
}

This function instructs the browser to retrieve all pages through the proxy on port 8080 of the server proxy.example.com. Should this proxy fail to respond, the browser contacts the Web-site directly, without using a proxy. 

Example from http://www.i88.ca/wpad.dat

function FindProxyForURL(url, host)
{
return "DIRECT; SOCKS5 localhost:1080; SOCKS5 localhost:8888";
}

A more complicated example demonstrates some available JavaScript functions to be used in the FindProxyForURL function:
function FindProxyForURL(url, host) {
 // our local URLs from the domains below example.com don't need a proxy:
 if (shExpMatch(host, "*.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";
}

Post a Comment

Featured Post

Setup Chinese Input Method in Ubuntu 17.10 Artful

sudo apt install ibus-sunpinyin After either of those commands do not forget to restart the IBus daemon ibus restart You might need t...