我在办公室,使用 HTTP 代理。它是在控制面板 (Windows 7) 中配置的。我想对特定域的简短列表使用不同的代理。我该如何实现?
答案1
用一个聚合氯化铝文件(代理自动配置)...
示例(来自维基百科):
function FindProxyForURL(url, host) {
// our local URLs from the domains below example.com don't need a proxy:
if (shExpMatch(host, "*.example.com")) {
return "DIRECT";
}
// URLs within this network are accessed through
// port 8080 on fastproxy.example.com:
if (isInNet(host, "10.0.0.0", "255.255.248.0")) {
return "PROXY fastproxy.example.com:8080";
}
// All other requests go through port 8080 of proxy.example.com.
// should that fail to respond, go directly to the WWW:
return "PROXY proxy.example.com:8080; DIRECT";
}
答案2
除了 pataluc 的答案之外,
此示例还向您展示了如何为简短的 URL 列表构建 PAC 文件
function FindProxyForURL(url, host) {
// fill in your own proxy
var proxy = "PROXY 192.168.1.1:8080";
if (shExpMatch(url, "http://www.firstwebsite.com*")) { return proxy; }
if (shExpMatch(url, "http://www.secondwebsite.com*")) { return proxy; }
if (shExpMatch(url, "http://www.thirdwebsite.com*")) { return proxy; }
// don't proxy all other URLs
return "DIRECT";
}