我有这个wpad.pac
function FindProxyForURL(url, host) {
if (isPlainHostName(host) ||
shExpMatch(host, "*.local") ||
isInNet(dnsResolve(host), "192.168.0.0", "255.255.255.0") ||
isInNet(dnsResolve(host), "127.0.0.0", "255.255.255.0"))
return "DIRECT";
return "PROXY 192.168.0.1:3128";
}我的服务器是Ubuntu18.04.1 x64,有Squid v3.5.27 (3128)和Apachev2.4.33,我用dhcp 252选项发布wpad.pac:
option wpad code 252 = text;
option wpad \"http://192.168.0.1:3500/wpad.pac\";该文件存储在:
/var/www/html/wpad.pac它发表在链接中:
http://192.168.0.1:3500/wpad.pac由apache使用wpad.conf管理:
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/
Options FollowSymLinks
DirectoryIndex wpad.pac
AllowOverride None
# serve proxy autoconfig correctly:
AddType application/x-ns-proxy-autoconfig .pac
Options Indexes FollowSymLinks MultiViews
AllowOverride ALL
Require all granted
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined在ports.conf中:
Listen 3500防火墙规则:
iptables -t mangle -A PREROUTING -i enp2s0 -p tcp --dport 3500 -j ACCEPT
iptables -A INPUT -s 192.168.0.0/24 -i enp2s0 -p tcp --dport 3500 -j ACCEPT
iptables -A FORWARD -s 192.168.0.0/24 -i enp2s0 -p tcp --dport 3500 -j ACCEPT它适用于Chrome 69.0.3497.100、IE v11.0.9600.19100和Opera 55.0.2994.61,但与默认配置Mozilla Firefox 62.0.2不兼容(我还没有用Edge进行测试,但与之无关)。但是Mozilla很好地加载了wpad.pac的URL,但是没有导航(在以前的版本中也不起作用)。
我的wpad.pac有什么问题?
重要:
alternative1:
function FindProxyForURL(url, host)
{
if (isInNet(host, "192.168.0.0", "255.255.255.0"))
return "DIRECT";
else
return "192.168.0.1:3128";
}function FindProxyForURL(url,host) {
var hostIP;
if (isIpV4Addr.test (host)) {
hostIP = host;
}
else {
hostIP = dnsResolve(host);
}
if (isInNet(hostIP, "192.168.0.0", "255.255.255.0")) {
return "DIRECT";
}
if (host == "localhost") {
return "DIRECT";
}
return "PROXY 192.168.0.1:3128";
}alternative3:
function FindProxyForURL(url, host) {return "PROXY 192.168.0.1:3128";}提前感谢
发布于 2018-10-29 17:30:03
升级到FirefoxQuantum63x时解决了这个问题
https://unix.stackexchange.com/questions/471423
复制相似问题