Proxy Auto-Config

Using a proxy auto - config file (PAC file) can find the appropriate proxy server for a desired URL web browser automatically.

A PAC file contains a JavaScript function FindProxyForURL ( url, host ). This function returns a string with one or more proxy specifications; with several specifications a fallback or failover in the event is possible that a server is not responding. The browser fetches this PAC file before requesting additional pages. The URL of the PAC file can be specified either manually or found automatically through the Web Proxy Auto Discovery Protocol.

Context

Modern browsers offer multiple configuration options - so you can choose the type that corresponds to the respective needs. It usually concerns the following options:

  • Manual proxy choice: There is a host name and a port number is specified, which are used for all URLs. Most still domains such as the own computer ( localhost) can be listed, for which the proxy is bypassed.
  • Proxy auto -configuration (PAC ): By specifying the URL of a PAC file using a suitable proxy for each URL is possible. It contains a JavaScript function that selects the appropriate proxy to any address. This option treats this article.
  • Web Proxy Auto Discovery Protocol ( WPAD protocol): The browser looks for the PAC file itself The protocol is discussed in a separate article.

The first possibility is the easiest.

The second (PAC ) is more flexible ( allowing the use of many different proxies). The URL of the PAC file must, however, once initially be manually specified.

The third option ( WPAD ) is based on PAC and makes this unnecessary manual work: Any browser an organization can therefore be instructed to use the same PAC configuration.

The PAC file

To use PAC, PAC files are usually published on web servers and the participatory browser instructed to read by specifying the corresponding address in the configuration settings or by use of the WPAD protocol. For testing purposes, or for other reasons can be held locally a PAC file but also quite.

A PAC file is a text file that defines a JavaScript function: FindProxyForURL ( url, host ). By default, they proxy.pac, the WPAD standard is used, it is often said that even wpad.dat. The server must be instructed x - ns -proxy- autoconfig specify a MIME type of the file application /.

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 redirect all page requests to the proxy on port 8080 of the server proxy.example.com. If this fails, then a direct connection is established to the WWW.

The following is a more complex example that demonstrates the use of some JavaScript functions demonstrated that stand for the FindProxyForURL feature is available:

Function FindProxyForURL ( url, host ) {     / / Addresses that are on example.com, do not need a proxy:     if ( shExpMatch (host, "*. example.com" )) {        return " DIRECT";     }       / / URLs within this network are queried about     / / Port 8080 on fastproxy.example.com: ( makes nameserver request)     if ( isInNet (host, " 10.0.0.0 ", " 255.255.248.0 " )) {        return " PROXY fastproxy.example.com: 8080 ";     }       / / All other requests go through port 8000 of proxy.example.com.     / / Should fail, connect directly to the network:     return " PROXY proxy.example.com: 8000; DIRECT"; } limitations

The function isInNet ( and other functions) perform a DNS query, which can block the browser if the DNS server is not responding. This feature is also on Windows systems, even with good accessibility quite "expensive", accesses to network resources can be slowed down.

The proxy caching in Microsoft Internet Explorer limits the flexibility of the PAC standards. Consequently, a proxy using the domain name, but not be chosen the path of the URL. Otherwise, the proxy caching must be switched off.

In principle, a PAC file are generated dynamically on the server.

663342
de