
Exampleof an optimizedproxypac
/— definition des adresses IP et du port des serveurs proxy —/
PROXY1 = « path1DNS:8080 »;
PROXY2 = « path2DNS:8080 »;
PROXY_RAD_CITRIX = « w.x.y.z:8080 »;
BlueCoat = « w.x.y.z:5555 »;
PROXY_LBR_F5 = « path3DNS:8080 »;
/— liste des adresses IP des serveurs intranet (accès en direct) —/
liste_IP = new Array;
liste_IP[« w.x.y.z »] = DIRECT;
…
/— Cas des URL en accès direct ou spécifique —/
liste_url = new Array;
liste_url[« http://application-URL »] = DIRECT;
…
/— Cas des adresses DNS de l’intranet (accès en direct sauf exception ci-dessous) —/
liste_domaine = new Array;
liste_domaine[« example.login.thomsonreuters.net »] = PROXY1;
liste_domaine[« example.domain.com »] = DIRECT;
liste_domaine[« example.domainDNS.uk »] = PROXY1;
liste_domaine[« example.domainDNS.co »] = PROXY2;
liste_domaine[« example.domainDNS.com »] = BlueCoat;
/— Cas des adresses domaine Office 365 —/
liste_domaine[« autodiscover.mondomaine.fr »] = PROXY-F5;
…
/==================================================================
SCRIPT
==================================================================/
function FindProxyForURL(url, host){
// Test des adresses IP
for (IPIndex in liste_IP) {
if (shExpMatch(host, IPIndex)) {
if (liste_IP[IPIndex] == « DIRECT ») {
return « DIRECT »;
} else {
return « PROXY » + liste_IP[IPIndex];
}
return
}
}
// Test des URL
for (urlIndex in liste_url) {
if (shExpMatch(url, urlIndex)) {
if (liste_url[urlIndex] == « DIRECT ») {
return « DIRECT »;
} else {
return « PROXY » + liste_url[urlIndex];
}
return
}
}
// Test des domaines
for (urlIndex in liste_domaine) {
if (dnsDomainIs(host, urlIndex)) {
if (liste_domaine[urlIndex] == « DIRECT ») {
return « DIRECT »;
} else {
return « PROXY » + liste_domaine[urlIndex];
}
}
}
// Si protocole HTTP => proxy primaire
if (url.substring(0, 5) == « http: ») {
return « PROXY » + PROXY1;
// Si protocole HTTPS => proxy primaire
} else if (url.substring(0, 6) == « https: ») {
return « PROXY » + PROXY1;
// Si protocole FTP => proxy primaire
} else if (url.substring(0, 4) == « ftp: ») {
return « PROXY » + PROXY1;
// Si protocole NNTP => proxy primaire
} else if (url.substring(0, 5) == « nntp: ») {
return « PROXY » + PROXY1;
}
}
Example of a non optimized proxy pac but functionnal:
/— definition des adresses IP et du port des serveurs proxy —/
PROXY0 = « principalProxy.domain.com:8080 »;
PROXYter = « proxyter.domain.com:8080 »;
PROXY2 = « proxy2.domain.com:8080 »;
PROXY_bis = « 192.168.x.y:5555 »;
PROXY_Autre = « 192.168.x.y »;
PROXY_bis = « 192.168.x.y;
PROXY_BC = « 192.168.x.y »;
Proxy1 = « mydomain.fr:8080 »;
/— liste des adresses IP des serveurs intranet (accès en direct) —/
var NB_IP = 2;
var INDEX_IP = 0;
LISTE_IP = new Array(NB_IP);
LISTE_IP[0]= »x.y.z.w »;
LISTE_IP[1]= »http://otherExample.net »;
/— Cas des adresses DNS de l’intranet (accès en direct sauf exception ci-dessous) —/
DNS_1 = « .domain.com »;
DNS_2 = « .login.domain.net »;
/— Office 365 domains —/
liste_domaine = new Array;
liste_domaine[« autodiscover.domain.fr »] = Proxy1;
…………….
/==================================================================
SCRIPT
==================================================================/
function FindProxyForURL(url, host) {
// Connexions directes pour les adresses IP locales
INDEX_IP = 0;
for (var i = 0; i < NB_IP; i++) {
if (url.indexOf(LISTE_IP[i]) >= 0) {
INDEX_IP = 1;
}
}
if(dnsDomainIs(host, DNS_2)){
return « PROXY » + PROXY0 + « ; DIRECT »;
}
….
if ((url.substring(0, 45) == « http://bbbbbb ») ||
(url.substring(0, 41) == « http://www.aaaaaa »)) {
return « PROXY » + PROXYter;
} else {
if ((url.substring(0, 39) == « adresse ») ||
(url.substring(0, 36) == « adresse ») ||
…
{
return « PROXY » + PROXY2;
} else {
if ((dnsDomainIs(host, DNS_1)) ||
(INDEX_IP == 1) ||
(url.substring(0, 30) == « http://www.yyyyyyy ») ||
(url.substring(0, 31) == « https://www.tttttt ») ||
(localHostOrDomainIs(host, « serv3. »)) ||
(localHostOrDomainIs(host, « serv2. »)) ||
(localHostOrDomainIs(host, « serv1. »))) {
return « DIRECT »;
} else {
// Domains
for (urlIndex in liste_domaine) {
if (dnsDomainIs(host, urlIndex)) {
if (liste_domaine[urlIndex] == « DIRECT ») {
return « DIRECT »;
} else {
return « PROXY » + liste_domaine[urlIndex];
}
}
}
// if HTTP => primary
if (url.substring(0, 5) == « http: ») {
return « PROXY » + PROXY0;
// If HTTPS => primary
} else if (url.substring(0, 6) == « https: ») {
return « PROXY » + PROXY0;
// Si protocole FTP => proxy primaire
} else if (url.substring(0, 4) == « ftp: ») {
return « PROXY » + PROXY0;
// Si protocole NNTP => proxy primaire
} else if (url.substring(0, 5) == « nntp: ») {
return « PROXY » + PROXY0;
}
}
}
}
}