Auto proxy configuration using DHCP
(DHCP3 server required)
For more information, see Web Proxy Autodiscovery Protocol
Also look at Microsoft Technet
Some handy javascript functions
This file assumes the IP of the DHCP server as well as the proxy servers are 192.168.0.1
apt-get install apache2 dhcp3-server
Edit /etc/apache2/httpd.conf and add this line:
AddType application/x-ns-proxy-autoconfig .dat
Edit /etc/dhcp3/dhcpd.conf (as well as /etc/ltsp/dhcpd.conf) and add this line:
option custom-proxy-server code 252 = text;
option custom-proxy-server “http://192.168.0.1/wpad.dat”;
Create the proxy configuration file ( /var/www/wpad.dat ). The code is javascript and the
function you have to implement is FindProxyForURL. Example contents to follow:
function FindProxyForURL(url, host)
{
// Add hostname exceptions for sites you do not want to
// proxy e.g. internal servers
if(shExpMatch(url,”*.softco/*”)) { return “DIRECT”; }
if(shExpMatch(url,”*.softco:*/*”)) { return “DIRECT”; }
if(shExpMatch(url,”*micky/*”)) { return “DIRECT”; }
if(shExpMatch(url,”*micky:*/*”)) { return “DIRECT”; }
if(shExpMatch(url,”*pluto/*”)) { return “DIRECT”; }
if(shExpMatch(url,”*pluto:*/*”)) { return “DIRECT”; }
if(shExpMatch(url,”*goofy/*”)) { return “DIRECT”; }
if(shExpMatch(url,”*goofy:*/*”)) { return “DIRECT”; }
// End hostname exceptions
// If you want to allow a specific IP range to go direct, use the line
// below or remove it
if(isInNet(host, “10.0.0.0”, “255.0.0.0”)) { return “DIRECT”; }
if(isInNet(host, “192.168.0.0”, “255.255.0.0”)) { return “DIRECT”; }
if(isInNet(host, “172.16.0.0”, “255.240.0.0”)) { return “DIRECT”; }
// End network exceptions
// Always bypass for localhost – make sure these 3 lines remain
if (shExpMatch(host, “localhost*”) || shExpMatch(host, “127.0.0.1*”)) {
return “DIRECT”;
}
// The browser is on a specific network, so send it a specific proxy to use
// This is useful for multi-subnet networks with multiple CensorNet servers
// Remove if you do not need this
if(shExpMatch(url,”*.archive.ubuntu.com/*”)) { return “PROXY 192.168.0.1:3142”; }
if(shExpMatch(url,”*.archive.ubuntu.com:*/*”)) { return “PROXY 192.168.0.1:3142”; }
if(shExpMatch(url,”*.security.ubuntu.com/*”)) { return “PROXY 192.168.0.1:3142”; }
if(shExpMatch(url,”*.security.ubuntu.com:*/*”)) { return “PROXY 192.168.0.1:3142”; }
if(shExpMatch(url,”*download.virtualbox.org/*”)) { return “PROXY 192.168.0.1:3142”; }
if(shExpMatch(url,”*download.virtualbox.org/*”)) { return “PROXY 192.168.0.1:3142”; }
if(shExpMatch(url,”*ppa.launchpad.net/*”)) { return “PROXY 192.168.0.1:3142”; }
if(shExpMatch(url,”*ppa.launchpad.net:*/*”)) { return “PROXY 192.168.0.1:3142”; }
if(shExpMatch(url,”*dl.google.com/linux/*/deb/*”)) { return “PROXY 192.168.0.1:3142”; }
if(shExpMatch(url,”*dl.google.com:*/linux/*/deb/*”)) { return “PROXY 192.168.0.1:3142”; }
if(shExpMatch(url,”*packages.medibuntu.org/*”)) { return “PROXY 192.168.0.1:3142”; }
if(shExpMatch(url,”*packages.medibuntu.org:*/*”)) { return “PROXY 192.168.0.1:3142”; }
if(shExpMatch(url,”*www.scootersoftware.com/*”)) { return “PROXY 192.168.0.1:3142”; }
if(shExpMatch(url,”*www.scootersoftware.com:*/*”)) { return “PROXY 192.168.0.1:3142”; }
// Finally, if it isn’t to be bypassed and is not localhost, return
// the proxy IP and port to use
return “PROXY 192.168.0.1:3128”;
}