Sun Java System Web Proxy Server 4.0.8 Administration Guide

Example 5: Balance Proxy Load With dnsDomainIs()()

This example is more sophisticated. The example uses four proxy servers, with one of them acting as a hot standby for the others. If any of the remaining three proxy servers goes down, the fourth one takes over. The three remaining proxy servers share the load based on URL patterns, which makes their caching more effective. Only one copy of any document exists on the three servers, as opposed to one copy on each of them. The load is distributed as shown in the following table.

Table 17–3 Balance Proxy Load

Proxy  

Purpose  

#1 

.com domain

#2 

.edu domain

#3 

all other domains 

#4 

hot standby 

All local accesses should be direct. All proxy servers run on port 8080. You can concatenate strings by using the + operator.

function FindProxyForURL(url, host)
{
    if (isPlainhost name(host) || dnsDomainIs(host, ".mydomain.com"))
        return "DIRECT";

    else if (dnsDomainIs(host, ".com"))
        return "PROXY proxy1.mydomain.com:8080; " +
              "PROXY proxy4.mydomain.com:8080";

    else if (dnsDomainIs(host, ".edu"))
        return "PROXY proxy2.mydomain.com:8080; " +
              "PROXY proxy4.mydomain.com:8080";

    else
        return "PROXY proxy3.mydomain.com:8080; " +
              "PROXY proxy4.mydomain.com:8080";
}