1 Reply Latest reply: Feb 12, 2014 10:05 AM by lee.todd RSS

    Proxy.pac config issues

    lee.todd

      Hi all.

      I've been asked to change the way our pac file works. Currently we have 4 proxys split with 2 at one site and 2 at another.  the pac file used the clients IP and splits load by even or odd number.

      What we want now because of the way the sites are connected and bandwidth issues is to send clients on networks that connect to one DC out the proxys there and clients on networks that connect into the second DC out the proxys there but then to load across the 2 proxys with the even/odd setup.  this way we should minimise use on the already busy DC-DC connection and make use of all 4 proxys.

      I've had both setups working but cant get it to work when combining by network and IP.  Below is a copy of the file only showing a few sites to keep it small.  If anyone has any ideas as im stuck.  If I run it through the pac file tester from google is errors as below:

       

       

      C:\pacparser-1.3.1-win32>pactester.exe -p proxyl.pac -f url.txt
      JSERROR: PAC script:9:
          SyntaxError: missing ; before statement
      pacparser.c: pacparser_parse_pac_string: Failed to evaluate the pac script.
      pactester.c: Could not parse the pac file: proxyl.pac
      C:\pacparser-1.3.1-win32>
      
      


      Proxy config. proxy 1 and 2 at one site 3 and 4 at the other

       

       

      function FindProxyForURL(url, host) {
        if (dnsResolve(host)=="") return "DIRECT";
      // Set the default proxy variable that users get if they don’t match
      // any more specific rule. 
       
      proxy = "PROXY proxy1:8080"; PROXY proxy3:8080";
      // Site1 Proxy
      if (isInNet(myIpAddress(), "10.0.0.0", "255.0.0.0")) { 
       //  Load Balancing Code
       
      // Find the 4th octet
       var myip=myIpAddress()
       var ipbits=myip.split(".")
       var myseg=parseInt(ipbits[3])
       
      // Check to see if the 4th octect is even or odd
       if (myseg==Math.floor(myseg/2)*2) {
            // Even 
           proxy = "PROXY proxy1:8080; PROXY proxy2:8080";
       }
       else {
            // Odd
            proxy = "PROXY proxy2:8080; PROXY proxy1:8080";
      }
      }
      // Site2 Proxy
      if (isInNet(myIpAddress(), "172.16.0.0", "255.240.0.0")) { 
       //  Load Balancing Code
       
      // Find the 4th octet
       var myip=myIpAddress()
       var ipbits=myip.split(".")
       var myseg=parseInt(ipbits[3])
       
      // Check to see if the 4th octect is even or odd
       if (myseg==Math.floor(myseg/2)*2) {
            // Even 
           proxy = "PROXY proxy3:8080; PROXY proxy4:8080";
       }
       else {
            // Odd
            proxy = "PROXY proxy4:8080; PROXY proxy3:8080";
      }
      }
        
        
      // No proxy for internal servers and listed domains
         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") ||
        isInNet(dnsResolve(host), "128.0.0.0", "255.128.0.0"))
        
       {
          return "DIRECT";
        }
        else 
        {
       // Default return condition is the proxy, since it’s assumed that everything
       // else is on the Internet.
        
       return proxy;
       }
      }
      }
      
      


      Any help much appreciated

       

      Lee