Skip to content

Instantly share code, notes, and snippets.

@tjgruber
Last active April 5, 2017 09:13
Show Gist options
  • Save tjgruber/3ed9f6dd598193e01144 to your computer and use it in GitHub Desktop.
Save tjgruber/3ed9f6dd598193e01144 to your computer and use it in GitHub Desktop.
Used for deployment of Proxy
function FindProxyForURL(url, host) {
// If the hostname matches the domains below, send direct (bypass proxy).
if (dnsDomainIs(host, ".your.domain") ||
dnsDomainIs(host, ".domain1.com") ||
dnsDomainIs(host, ".domain2.com"))
return "DIRECT";
// If the protocol or URL matches, send direct.
// if (url.substring(0, 4)=="ftp:" ||
// shExpMatch(url, "http://abcdomain.com/folder/*"))
// return "DIRECT";
// If the requested website is hosted within the internal network, send direct.
if (isPlainHostName(host) ||
shExpMatch(host, "*.local") ||
isInNet(dnsResolve(host), "10.0.0.0", "255.0.0.0") ||
isInNet(dnsResolve(host), "172.16.0.0", "255.240.0.0") ||
isInNet(dnsResolve(host), "192.168.0.0", "255.255.0.0") ||
isInNet(dnsResolve(host), "127.0.0.0", "255.255.255.0"))
return "DIRECT";
// If the IP address of the local machine is within a defined subnet, send to a specific proxy.
// if (isInNet(myIpAddress(), "10.10.5.0", "255.255.255.0"))
// return "PROXY 192.168.3.210:3128";
// DEFAULT RULE: All other traffic, use below proxies, in fail-over order.
return "PROXY serv-proxy1.your.domain:3128; PROXY serv-proxy2.your.domain:3128; DIRECT";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment