SHIFT

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


proxypac
Differences

This shows you the differences between two versions of the page.

Link to this comparison view

proxypac [2013/03/26 21:04] (current)
sjoerd created
Line 1: Line 1:
 += Proxy Pac =
  
 +If you've created a [[squid|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 ==
 +
 +<​code>​
 +/*
 + * 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";​
 +  }
 +}
 +</​code>​
 +
 +Note that you need a DNS record for the proxy
 +
 +== 2nd example ==
 +
 +<​code>​
 +function FindProxyForURL(url,​ host) 
 +{
 +  // our local URLs from the domains below don't need a proxy:
 +  if (shExpMatch(url,​ "​*.wiki.getshifting.com*"​)) {
 +  return "​DIRECT";​
 +  } else {
 +  // All other requests go through port 3128 of proxy.getshifting.com.
 +  return "PROXY proxy.getshifting.com:​3128";​
 +  }
 +}
 +</​code>​
 +
 +== File ==
 +
 +To use a proxy.pac file place it in the document root of your webserver:
 +
 +<​code>​
 +cat /​etc/​apache2/​default-server.conf | grep -i root
 +DocumentRoot "/​srv/​www/​htdocs"​
 +</​code>​
 +
 +Now you can enter an "​automatic proxy configuration url" (firefox) or "Use automatic configuration script"​ (Internet explorer). The address would be:
 +
 +<​code>​
 +http://​proxy.5p-it.com/​proxy.pac
 +</​code>​
 +
 += More information =
 +
 +All the possible options are described here: \\
 +http://​lib.ru/​WEBMASTER/​proxy-live.txt ​
 +
 +{{tag>​network apache}}
proxypac.txt ยท Last modified: 2013/03/26 21:04 by sjoerd