= Proxy Pac =
**Summary**: A basic proxy pac script to manage your internal network for outgoing and intranet network traffic. \\
**Date**: Around 2014 \\
**Refactor**: 22 March 2025: Checked links and formatting. \\
{{tag>azure vpn}}
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 ==
/*
* 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";
}
}
Note that you need a DNS record for the proxy
== 2nd example ==
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";
}
}
== File ==
To use a proxy.pac file place it in the document root of your webserver:
cat /etc/apache2/default-server.conf | grep -i root
DocumentRoot "/srv/www/htdocs"
Now you can enter an "automatic proxy configuration url" (firefox) or "Use automatic configuration script" (Internet explorer). The address would be:
http://proxy.5p-it.com/proxy.pac
= More information =
All the possible options are described here: \\
http://lib.ru/WEBMASTER/proxy-live.txt