Talk:Proxy auto-config

From Wikipedia, the free encyclopedia

Contents

[edit] PAD file can be a local file.

Instructions from here: http://nscsysop.hypermart.net/proxypac.html

Autoconfigure the Proxy Settings from a Local Copy of the PROXY.PAC File (IE or Netscape)

In this method, useful for laptops that travel on and off your LAN, you copy the file to some local directory, and point to it.

1. Copy the PROXY.PAC file to the C:\WINDOWS directory, or other directory of your choice. 2. In the browser proxy settings, configure the Automatic Proxy Configuration (Netscape) or Use Automatic Configuration Script (IE) URL to:


Netscape, use: file:///c|/windows/proxy.pac

Internet Explorer, use: file://c:/windows/proxy.pac

In Netscape, click on the Reload button.


However, this removes the ability to change the proxy settings on the fly.
Axel Eble 15:46, 21 June 2006 (UTC)

Only newer versions of Internet Explorer can use a local PAC file. 90.49.223.248 (talk) 17:31, 1 February 2008 (UTC) Ninho


[edit] Efficient direct intranet configuration

From the Google Accelerator project:

var proxy = "PROXY proxy.example.com:3128";

function FindProxyForURL (url, host) {
  if (host == "localhost" || host == "127.0.0.1" ||
      private_re.test(host) ||
      isPlainHostName (host) ||
      url.substring(0, 6) == "https:"
     )
    return "DIRECT";

  return proxy + "; DIRECT";
}

/* quick version to avoid DNS resolving, performs a regular expression to
 * detect RFC 1918, RFC 1112, 239/24 bogon, and class E experimental ranges.
 */
var private_re = new RegExp("^((0\\.0\\.0\\.0)|(127\\.\\d+\\.\\d+\\.\\d+)|(10\\.\\d+\\.\\d+\\.\\d+)|(172\\.(1[6789]|2[0-9]|3[01])\\.\\d+\\.\\d+)|(169\\.254\\.\\d+\\.\\d+)|(192\\.168\\.\\d+\\.\\d+)|(22[3-9]\\.\\d+\\.\\d+\\.\\d+)|(2[3-5][0-9]\\.\\d+\\.\\d+\\.\\d+))$");

A more traditional approach to RFC 1918 finding would be like this:

function isRFC1918 (host) {
  var ip = dnsResolve(host);
  if (isInNet(ip, "127.0.0.0", "255.0.0.0") ||
      isInNet(ip, "10.0.0.0", "255.0.0.0") ||
      isInNet(ip, "172.16.0.0", "255.240.0.0") ||
      isInNet(ip, "192.168.0.0", "255.255.0.0"))
  {
    return true;
  }
  return false;
}

[edit] Load sharing and high availability

Sharp in 1996 created the Super Proxy Script a auto-config proxy script that selects proxy servers based upon a hash value of the URL requested. Later updated in 1997 to work optimally with HTTP 1.1 by sending matching directories to the same proxy.

Many mechanisms exist for creating the hash, some are listed below.

[edit] Fourth IP octet

As per Novell Cool Solutions:

function URLhash (name) {
  var ip = dnsResolve(host);
  var octets = ip.split(".");
  return parseInt(octets[3]);
}

[edit] Hostname hash

As MSIE caches the proxy per host it is redundant to calculate the hash for the directory. The JavaScript language has also advacned to include charAt() and charCodeAt() to simplify the code even further.

var proxy0 = "PROXY 192.168.0.1:3128";
var proxy1 = "PROXY 192.168.0.2:8080";

function FindProxyForURL(url, host)
{
  ret = HostHash(host);
  if ((ret % 3) < 2)
    return proxy0 + "; " + proxy1 + "; DIRECT";
  return proxy1 + "; " + proxy0 + "; DIRECT";
}

function HostHash(host)
{
  var cnt = 0; 
  if (host.length == 0)
    return cnt; 

  for (var i = host.length - 1; i >= 0; i--)
    cnt = cnt + host.charCodeAt(i);
 
  return cnt;
}

220.232.210.142 10:46, 23 October 2007 (UTC)