4/17/2007

浏览器上网代理解决方案 - 自动代理配置脚本

Firefox代理插件用来用去,各有各的问题,最终发现还是PAC(Proxy Automatic Configuration)脚本最强,通过PAC,基本上Foxproxy(我用过的一个很复杂的Firefox代理插件)的功能都能实现。

我理想中的上网代理解决方案:

1、应该支持Firefox和IE两种浏览器,因为有时不得不用IE,如起点中文、大部分网上银行;
2、支持多代理服务器(我的要求是两个);
3、不用人工去网上搜索、尝试代理服务器,那样太麻烦、太辛苦;
5、不是重点但也需要考虑的部分-如果能为那些无法设置代理的软件(如Zoundry Blog Writer)考虑就完美了。

具体配置:
Firefox/IE;QuickProxy(optional);PAC文件[下载InternetProxy.pac]
三个本地代理软件(两个用于提供本地代理服务器,另一个用于支持无代理设置功能的软件通过代理上网);

Tips:

注意pac文件的保存格式,ultraedit的默认保存格式可能会有问题;
指定PAC文件配置后需要重启浏览器;
改动pac文件后需要重启浏览器;

附录 - 我的PAC文件InternetProxy.pac [我的Google Pages主页]

// ==================================================
// Automatic proxy configuration Script V0.2
//
// 作者 :
// 博客 :
// Email :
// Thanks :
// Note : Firefox配置的URL类似file:///C:/proxy.pac
// IE配置的URL类似file://C:\proxy.pac
//
// 两个代理服务器(下载代理软件,如Tor等可提供本地代理服务)
//==================================================

function FindProxyForURL(url, host){

host = host.toLowerCase();

//1-本地网络的服务器直接连接
if (isInNet(host, "198.168.1.0", "255.255.255.0") || isPlainHostName(host)){
return "DIRECT";
}

//2-外网服务器
if(dnsDomainIs(host,"secure.wikimedia.org")) //2.1-少数例外的外网服务器
return "DIRECT";
else if(
dnsDomainIs(host,"wikipedia.org")
||dnsDomainIs(host,"wikisource.org")
||dnsDomainIs(host,"wikibooks.org")
||dnsDomainIs(host,"wikimedia.org")
||dnsDomainIs(host,"wiktionary.org")
||dnsDomainIs(host,"wikinews.org")
||dnsDomainIs(host,"wikimediafoundation.org")
||dnsDomainIs(host,"mediawiki.org")
||dnsDomainIs(host,"wikiquote.org")
|| dnsDomainIs(host,"technorati.com")
|| dnsDomainIs(host,"voanews.com")
|| dnsDomainIs(host,"mediawiki.org")
|| dnsDomainIs(host,"bbc.co.uk")
|| dnsDomainIs(host,"xys.org")
|| dnsDomainIs(host,"worldjournal.com")
|| dnsDomainIs(host,"chinesenewsnet.com")
//......增加网址在这里添一行
|| shExpMatch(url, "http://*.google.com/search?*") //匹配google搜索
)
return "PROXY 127.0.0.1:8567"; //2.2-部分外网服务器走代理服务器一: 8567

else if(
dnsDomainIs(host,"blogspot.com")
||dnsDomainIs(host,"?") //other sites
)
return "PROXY 127.0.0.1:9666"; //2.3-部分外网服务器走代理服务器二: 9666
else if (!isResolvable(host)) return "127.0.0.1:8567"; //2.4-不能解析的外网服务器用代理服务器一
else return "DIRECT"; //2.5-其它的外网服务器直连
}

Technorati :

没有评论:

为什么说普京已经输掉了这场战争

  为什么说普京已经输掉了这场战争 作者: Yuval Noah Harari (历史学家畅销书【智人:人类简史】的作者) 译自: 英国卫报, 2022年2月28日 翻译: Andywho in Canada 原文链接: Why Vladimir Putin has alread...