Proxy auto-config

From Wikipedia, the free encyclopedia

The proxy auto-config file defines how web browsers can automatically choose the appropriate proxy server for fetching a given URL:

A PAC file contains a JavaScript function "FindProxyForURL(url, host)". This function returns a string with one or more proxy specifications.

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.

Contents

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 discussed in this article.

The first option is the most basic (and most secure). The second option (PAC) is more flexible (allowing many different proxies to be used). Still, you have to set the URL of the PAC file once manually. The third option (WPAD) builds on top of PAC and removes this requirement of manual configuration: You can instruct all browsers within your organisation to use the same PAC configuration.

To use PAC, you publish a PAC file on a Web server and instruct your browser to read it (either by entering the URL in the proxy connection settings of your browser or by using the WPAD protocol).

A PAC file is a text file that defines one JavaScript function FindProxyForURL(url, host). By convention, this file is often named proxy.pac, but when using the WPAD standard, it's often called wpad.dat. You must instruct your web server to declare the mime type of this file to be: application/x-ns-proxy-autoconfig.

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";
  }

Here is a Lists of predefined functions available for use.

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

Proxy caching in Microsoft's Internet Explorer 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 Proxy caching. Refer to "Frequently Given Answer" Automatic proxy HTTP server configuration in web browsers 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 properly

Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.