0

I have a squid + diladele proxy box in my network. I have setup a PAC file that should do the following:

1)If the ip address of the client belongs to the current network (192.168.0.0/24) and tries to access a resource outside the network use the proxy. 2)If the client is trying to access an internal resource, give direct access and bypass proxy

Here is what I wrote so far

// If the IP address of the local machine is within a defined
// subnet, send to a specific proxy.
    if (isInNet(myIpAddress(), "192.168.0.0", "255.255.255.0"))
        return "PROXY 192.168.0.253:3128";

// If the requested website is hosted within the internal network, send direct.
    if (isPlainHostName(host) ||
        shExpMatch(host, "*local") ||
        isInNet(dnsResolve(host), "192.168.0.0","255.255.0.0") ||
        isInNet(dnsResolve(host), "127.0.0.1", "255.255.255.255")||
        shExpMatch(host,"localhost"))
        return "DIRECT";
// DEFAULT RULE: All other traffic, use below proxies, in fail-over order.
        return "DIRECT";

Everything works perfectly, however when I try to access a resource on localhost ( I have a lamp stack on my device ) for some reason I get redirected to my proxy web interface (192.168.0.253). What am I doing wrong?

Aaron Ullal
  • 163
  • 1
  • 2
  • 10

1 Answers1

0

This might shed some light as to what is happening at:

if (isInNet(myIpAddress(), "192.168.0.0", "255.255.255.0"))
    return "PROXY 192.168.0.253:3128";

"The myIpAddress function has often been reported to give incorrect or unusable results, e.g. 127.0.0.1, the IP address of the localhost. It may help to remove on the system's host file (e.g. /etc/hosts on Linux) any lines referring to the machine host-name, while the line 127.0.0.1 localhost can, and should, stay. On Internet Explorer 9, isInNet("localHostName", "second.ip", "255.255.255.255") returns true and can be used as a workaround. The myIpAddress function assumes that the device has a single IPv4 address. The results are undefined if the device has more than one IPv4 address or has IPv6 addresses."

https://en.wikipedia.org/wiki/Proxy_auto-config#The_PAC_File

Sam Perry
  • 41
  • 5