Advertise on warmetal.nl!
Click for more information
about advertising here.

Did you find this website useful? Did I save you a lot of time?
Please consider donating to support this site:

 

Proxy Pac

If you've created a proxy server you can create an automatic proxy script so your users don't have to turn off the proxy for internal addresses and it's easier to make changes.

An example proxy pac file

/*
 * Standard proxy.pac automatic proxy configuration.
 *
 * sjoerd [@] warmetal.nl
 * 22 aug 2008
 *
 * Will not proxy for short hostnames for domain.local and raw URL http://10.*
 *
 */

function FindProxyForURL(url, host)
{
 // If no domain name in the host(no dots) are found go DIRECT
  if (isPlainHostName(host) || dnsDomainIs(host, ".domain.local"))
  {
     return "DIRECT";
  }
  else if (url.substring(0, 10) == "http://10." ||
           url.substring(0, 11) == "https://10." ||
           url.substring(0, 11) == "http://127." ||
           url.substring(0, 12) == "https://127." )
  {
     return "DIRECT";
  }
  else
  {
     return "PROXY proxy:8080";
  }
}

Note that you need a DNS record for the proxy

2nd example

function FindProxyForURL(url, host)
{
  // our local URLs from the domains below don't need a proxy:
  if (shExpMatch(url, "*.wiki.5p-it.com*")) {
  return "DIRECT";
  } else {
  // All other requests go through port 3128 of proxy.5p-it.com.
  return "PROXY proxy.5p-it.com:3128";
  }
}

File

To use a proxy.pac file place it in the document root of your webserver:
cat /etc/apache2/default-server.conf | grep -i root
DocumentRoot "/srv/www/htdocs"

Now you can enter an “automatic proxy configuration url” (firefox) or “Use automatic configuration script” (Internet explorer). The address would be:

http://proxy.5p-it.com/proxy.pac

More information

All the possible options are described here:
http://lib.ru/WEBMASTER/proxy-live.txt

Discussion

Enter your comment:
 
proxypac.txt · Last modified: 2010/08/17 10:04 (external edit)