contatore free

solutioncafe IT

Il System Architect è il punto di unione tra IT, processi aziendali e esigenze del cliente

dic
2008
10

Uno script di autoconfigurazione con estensione *.pac, chiamato per comodità proxy.pac contiene genericamente una funzione JavaScript chiamata “FindProxyForURL(url, host)” che restituisce uno o più risultati, basandosi su condizioni definite dal gestore del sistema di proxy, che un moderno browser è in grado di interpretare.
Viene solitamente utilizzato quando è necessario discriminare la modalità di navigazione al fine di indirizzare l’utente, in modo trasparente, a rivolgere la sua richiesta attraverso il proxy oppure in modalità “diretta”.
Eccone un esempio:

function FindProxyForURL(url, host)
{
       if (isPlainHostName(host))
       {
       return "DIRECT";
       }
// NAME HOSTS --> DIRECT

        if ((host=="domainname.it")||
            (host=="domainname.com"))
        {
        return "DIRECT";
        }

// NAME HOSTS --> PROXY

        if ((host=="abcd.domainname.it")||
            (host=="efgh.subdomain.domainname.it"))
        {
        return ProxyServer(url);
        }

// IP HOSTS --> DIRECT

        if ((host=="10.60.50.141") ||      // Servizio XYZ;
            (host=="10.32.1.103"))          // Servizio ZXY;
        {
        return "DIRECT";
        }

// IP HOSTS --> PROXY A

        if ((host=="10.128.64.50")   ||    // Servizio A
            (host=="10.51.8.50")     ||     // Servizio B
            (host=="10.51.76.202"))        // Servizio C
        {
        return ProxyServer(url);
        }

// IP HOSTS --> PROXY B;

        if ((host=="XXX.201.99.120") ||
            (host=="YYY.223.212.242") ||
            (host=="ZZZ.221.99.154"))
        {
        return "PROXY aa.bbb.ccc.d:8080; DIRECT";
        }

 //LOCAL DOMAIN NAME --> DIRECT

        if (dnsDomainIs(host, "subdomain.mydomain.it") ||
            dnsDomainIs(host, "subdomain.mydomain.com") ||
            dnsDomainIs(host, "internaldomain.loc") ||
            dnsDomainIs(host, "otherdomain.it"))
        {
        return "DIRECT";
        }

//PRIVATE NETWORK --> DIRECT

        if (isInNet(host, "10.0.0.0", "255.0.0.0") ||
            isInNet(host, "127.0.0.0", "255.0.0.0")  ||
            isInNet(host, "172.16.0.0", "255.240.0.0")  ||
            isInNet(host, "192.168.0.0", "255.255.0.0"))
        {
        return "DIRECT";
        }

        // otherwise use Proxy Server

        else

        function ProxyServer(url);

function ProxyServer(url) {
   return "PROXY cache.internaldomain.it:3128; DIRECT";
}

Il proxy.pac per essere utilizzato deve essere messo in linea su un web server opportunamente configurato, argomento che tratteremo in un prossimo articolo.

Per ulteriori informazioni sull’uso degli script di autoconfigurazione consultate Wikipedia
Per verificare la sintassi e/o i risultati del vostro proxy.pac potete utilizzare pactester.

Tag:

I commenti sono chiusi.

Banner