我在我的网络里有一个乌贼+老二代理盒。我已经设置了一个PAC文件,它应该执行以下操作:
1)如果客户端的ip地址属于当前网络(192.168.0.0/24),并试图访问网络外的资源,则使用代理。2)如果客户端试图访问内部资源,则直接访问并绕过代理。
以下是我迄今为止所写的
// 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";但是,当我试图访问localhost上的资源(我的设备上有一个灯堆栈)时,一切都很完美,因为某种原因,我被重定向到代理web接口(192.168.0.253)。我做错了什么?
发布于 2016-02-26 09:07:22
这可能有助于了解在下列情况下发生的情况:
if (isInNet(myIpAddress(), "192.168.0.0", "255.255.255.0"))
return "PROXY 192.168.0.253:3128";“myIpAddress函数经常被报告给出不正确或不可用的结果,例如127.0.0.1,本地主机的IP地址。它可能有助于删除系统的主机文件(例如,Linux上的/etc/ host )中提到计算机主机名的任何行,而行127.0.0.1本地主机可以并且应该保留。在Internet 9上,isInNet("localHostName“、"second.ip”、“255.255.255”)返回true,可用作解决方法。myIpAddress函数假定设备只有一个IPv4地址。如果设备有多个IPv4地址或有IPv6地址,则结果是未定义的。“
https://serverfault.com/questions/759956
复制相似问题