Search code examples
proxypac

PAC File Return Options towards localhost


Unable to find a definite answer in regards to my question. I was wondering if it was possible to poison the pac file to point to loopback address so that the traffic dies out. Seems that the traffic I am pointing to 127.0.0.1 is still going towards the proxy. Was wondering if I am doing this wrong and if I need to put "return Proxy 127.0.0.1".

The reason I want to poison this towards loopback is because the traffic is blocked but to lower the CPU utilization of my proxy I want to let this traffic die out locally (on the computer) as it keeps being denied on the proxy. Causing high CPU.

function FindProxyForURL (url , host){

//General exception from a more general rule
if (isPlainHostName(host)) return "DIRECT";

//Localhost
else if (shExpMatch(host, "test.example.com")) return "127.0.0.1";
}

Solution

  • Yes the block return string needs to start with "PROXY" and it should also have a port number.

    I generally use something like this as a skeleton:

    var ALLOW = "DIRECT";
    var BLOCK = "PROXY 127.0.0.1:65535";
    
    
    function FindProxyForURL(url, host)
    {
      if (dnsDomainIs(host,"example.org")) return BLOCK; 
      return ALLOW;
    }