Skip to content

Instantly share code, notes, and snippets.

@SystemJargon
Created April 20, 2024 06:19
Show Gist options
  • Save SystemJargon/f75f5d3274036010bb9d20c7899079af to your computer and use it in GitHub Desktop.
Save SystemJargon/f75f5d3274036010bb9d20c7899079af to your computer and use it in GitHub Desktop.
Example proxy.pac configuration file
// This is just an example proxy.pac and is NOT to be used in production without changes to suit your environment.
//
// Some references about Proxy configuration below.
// https://wiki.squid-cache.org/SquidFaq/ConfiguringBrowsers
// https://learn.microsoft.com/en-us/troubleshoot/developer/browsers/connectivity-navigation/optimize-pac-performance
function FindProxyForURL(url, host) {
/* Normalize the URL for pattern matching */
url = url.toLowerCase();
host = host.toLowerCase();
/* Don't proxy local hostnames */
if (isPlainHostName(host))
{
return 'DIRECT';
}
// replace .local with your own domains
/* Don't proxy local domains */
if (dnsDomainIs(host, ".local") ||
(host == ".local") ||
{
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 1.2.3.4:8080";
// DEFAULT RULE: All other traffic, use below proxy.
// 172.16.1.2 should be replaced by your actual proxy IP address.
// 3128 should be replaced by your actual proxy listening port.
return "PROXY 172.16.1.2:3128; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment