Proxy auto-config

Proxy auto-config

The proxy auto-config file defines how web browsers and other user agents can automatically choose the appropriate proxy server (access method) for fetching a given URL.

A PAC file contains a JavaScript function "FindProxyForURL(url, host)". This function returns a string with one or more access method specifications. These specifications cause the user agent to use a particular proxy server or to connect directly.

Multiple specifications provide a fallback when a proxy fails to respond. The browser fetches this PAC file before retrieving other pages. The URL of the PAC file is either configured manually or determined automatically by the Web Proxy Autodiscovery Protocol.

Context

Modern web browsers implement several levels of automation; you can choose the level that is appropriate to your needs. The following methods are commonly implemented:

* Manual proxy selection: Specify a hostname and a port number to be used for all URLs. Most browsers allow you to specify a list of domains (such as localhost) that will bypass this proxy.
* Proxy auto-configuration (PAC): Specify the URL for a PAC file with a JavaScript function that determines the appropriate proxy for each URL. This method is more suitable for laptop users who need several different proxy configurations, or complex corporate setups with many different proxies, and is discussed in this article.
* Web Proxy Autodiscovery Protocol (WPAD): Let the browser guess the location of the PAC file through DHCP and DNS lookups. This is discussed in a separate article.

The PAC File

To use PAC, you publish a PAC file on a Web server and instruct a user agent to utilize it, either by entering the URL in the proxy connection settings of your browser or through the use of the WPAD protocol.

A PAC file is a text file that defines at least one JavaScript function, FindProxyForURL(url, host). By convention, this file is normally named proxy.pac. The WPAD standard uses wpad.dat.

Even though most clients will process the script regardless of the MIME type returned in the HTTP request, for the sake of completeness and to maximize compatibility, you should instruct your web server to declare the MIME type of this file to be either application/x-ns-proxy-autoconfig or application/x-javascript-config.

There is little evidence to favor the use of one MIME type over the other. It would be, however, reasonable to assume that application/x-ns-proxy-autoconfig will be supported in more clients than application/x-javascript-config as it was defined in the original Netscape specification, the latter type coming in to use more recently.

A very simple example of a PAC file is: function FindProxyForURL(url, host) { return "PROXY proxy.foo.com:8080; DIRECT"; }This function instructs the browser to retrieve all pages through the proxy on port 8080 of the server proxy.foo.com. Should this proxy fail to respond, the browser contacts the WWW directly, without using a proxy.

Here is a more complicated example demonstrating some available JavaScript functions to be used in the FindProxyForURL function:

function FindProxyForURL(url, host) { // our local URLs from the domains below foo.com don't need a proxy: if (shExpMatch(url,"*.foo.com/*")) {return "DIRECT";} if (shExpMatch(url, "*.foo.com:*/*")) {return "DIRECT";} // URLs within this network are accessed through // port 8080 on fastproxy.foo.com: if (isInNet(host, "10.0.0.0", "255.255.248.0")) { return "PROXY fastproxy.foo.com:8080"; } // All other requests go through port 8080 of proxy.foo.com. // should that fail to respond, go directly to the WWW: return "PROXY proxy.foo.com:8080; DIRECT"; }

Limitations

The function dnsResolve (and similar other functions) performs a DNS lookup that can block your browser for a long time if the DNS server does not respond.

Caching of proxy autoconfiguration results by domain name in Microsoft's Internet Explorer 5.5 or higher limits the flexibility of the PAC standard. In effect, you can choose the proxy based on the domain name, but not on the path of the URL. Alternatively, you need to disable caching of proxy autoconfiguration results by editing the registry. Refer to the article by de Boyne Pollard (listed in #Further_reading) for more details.

It is recommended to always use IP instead of host domain names in isInNet function for compatibilities with other components in Windows which makes use of Internet Explorer PAC settings, such as .NET 2.0 Framework. For example, if (isInNet(host, dnsResolve(sampledomain) , "255.255.248.0") // .NET 2.0 will resolve proxy properly if (isInNet(host, sampledomain, "255.255.248.0") // .NET 2.0 will not resolve proxy properlyThe current convention is to fail over to direct connection when a PAC file is unavailable.

Further limitations are related to the JavaScript engine on the local machine.

Further reading

External links

* [http://www.microsoft.com/technet/prodtechnol/ie/reskit/6/part6/c26ie6rk.mspx?mfr=true Description of proxy auto-configuration files from Microsoft]
* [http://code.google.com/p/pacparser pacparser] C and Python library to parse PAC files.
* [http://code.google.com/p/pactester Pactester] A tool to test PAC files.
* [http://luno.org/project/proxyvalidator/ proxyvalidator] Test all destination proxies within a PAC file.
* [http://www.schooner.com/~loverso/no-ads/ PAC-file to filter online advertisement]
* [http://www.securemecca.com/pac.html PAC-file to filter bad hosts and pornography]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Proxy Auto-Config — Anhand einer Proxy Auto Config Datei (PAC Datei) kann ein Webbrowser automatisch den passenden Proxyserver für eine gewünschte URL finden. Eine PAC Datei enthält eine JavaScript Funktion FindProxyForURL(url, host). Diese Funktion gibt einen… …   Deutsch Wikipedia

  • Proxy (Rechnernetz) — Ein Proxy (von englisch proxy representative ‚Stellvertreter‘, von lateinisch proximus ‚der Nächste‘) ist eine Kommunikationsschnittstelle in einem Netzwerk. Er arbeitet als Vermittler, der auf der einen Seite Anfragen entgegennimmt, um …   Deutsch Wikipedia

  • Proxy-Server — Ein Proxy (von engl. „proxy representative“ = Stellvertreter, bzw. lat. „proximus“ = der Nächste) arbeitet als Vermittler, der auf der einen Seite Anfragen entgegennimmt, um dann über seine eigene Adresse eine Verbindung zur anderen Seite… …   Deutsch Wikipedia

  • Proxy Server — Ein Proxy (von engl. „proxy representative“ = Stellvertreter, bzw. lat. „proximus“ = der Nächste) arbeitet als Vermittler, der auf der einen Seite Anfragen entgegennimmt, um dann über seine eigene Adresse eine Verbindung zur anderen Seite… …   Deutsch Wikipedia

  • Proxy.pac — Anhand einer Proxy Auto Config Datei (PAC Datei) kann ein Webbrowser automatisch den passenden Proxyserver für eine gewünschte URL finden. Eine PAC Datei enthält eine JavaScript Funktion FindProxyForURL(url, host). Diese Funktion gibt einen… …   Deutsch Wikipedia

  • Web Proxy Autodiscovery Protocol — Web Proxy Auto Discovery Protocol (WPAD) (протокол автоматической настройки прокси)  метод, используемый клиентами для определения места (URL) расположения конфигурационного файла с использованием технологий DHCP и/или DNS. После того, как… …   Википедия

  • Web Proxy Autodiscovery Protocol — The Web Proxy Autodiscovery Protocol (WPAD) is a method used by clients to locate a proxy auto config file automatically and use this to configure the browser s web proxy settings.The method is available as an IETF internet draft draft ietf wrec… …   Wikipedia

  • Web Proxy Autodiscovery Protocol — Das Web Proxy Autodiscovery Protocol (WPAD) ist ein Protokoll, mit dem Web Clients wie ein Browser automatisiert zu verwendende Web Proxies innerhalb eines Computernetzwerkes finden können, indem eine Proxy autoconfiguration (PAC) Datei unter… …   Deutsch Wikipedia

  • Offener Proxy — Ein Proxy (von engl. „proxy representative“ = Stellvertreter, bzw. lat. „proximus“ = der Nächste) arbeitet als Vermittler, der auf der einen Seite Anfragen entgegennimmt, um dann über seine eigene Adresse eine Verbindung zur anderen Seite… …   Deutsch Wikipedia

  • Offener Proxy-Server — Ein Proxy (von engl. „proxy representative“ = Stellvertreter, bzw. lat. „proximus“ = der Nächste) arbeitet als Vermittler, der auf der einen Seite Anfragen entgegennimmt, um dann über seine eigene Adresse eine Verbindung zur anderen Seite… …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”