====== Automatic proxy configuration ====== **DRAFT** ===== DHCP way ===== * Works for IE # autoproxy option wpad-url code 252 = text; option wpad-url "http://wpad.domain.lan/proxy.php "; # space (or any other character) at the end must be in place as a workaround related to the IE bug ===== DNS way ===== * Works for Firefox * URL: http://wpad.domain.lan/wpad.dat * DNS record: wpad.domain.lan * wpad.dat have to be linked to proxy.php ln -s proxy.php wpad.dat * Apache site ServerName wpad.domain.lan AddType application/x-httpd-php .dat DocumentRoot /opt/company/autoproxy Options FollowSymLinks Order allow,deny Allow from all ===== Generate proxy.pac (wpad.dat) depend on source IP ===== * You might also be interested in [[smart-proxy-pac]] /* Creator: Stanislav German-Evtushenko (2012) * Contributor: add your name here */ function FindProxyForURL(url, host) { // Define default proxy dst_default = ""; //// If specific URL needs to bypass proxy, send traffic direct. // if (shExpMatch(url,"*domain.com*") || // shExpMatch(url,"*vpn.domain.com*")) // return "DIRECT"; // If URL has no dots in host name, send traffic direct. if (isPlainHostName(host)) return "DIRECT"; // If IP address is internal or hostname resolves to internal IP, send direct. resolved_ip = dnsResolve(host); if (isInNet(resolved_ip, "10.0.0.0", "255.0.0.0") || isInNet(resolved_ip, "172.16.0.0", "255.240.0.0") || isInNet(resolved_ip, "192.168.0.0", "255.255.0.0") || isInNet(resolved_ip, "127.0.0.0", "255.255.255.0")) return "DIRECT"; // Return default proxy return dst_default; } {{tag>browser javascript proxy proxy.pac scripting php}}