MozTW 討論區
https://forum.moztw.org/

請問proxy.pac的寫法
https://forum.moztw.org/viewtopic.php?f=11&t=41193
1 頁 (共 1 頁)

發表人:  konkon3141 [ 2014-08-07, 23:45 ]
文章主題 :  請問proxy.pac的寫法

請問proxy.pac的寫法
是那邊有問題嗎
怎麼特定網站沒有代理呢?
這是之前有人寫好的
最近才在改用怎麼沒有用呢?
路徑是file://C:/proxy.pac
引言回覆:
function FindProxyForURL(url, host)
{


if (dnsDomainIs(host, "www.xiami.co") ||

(dnsDomainIs(host, "www.xiami.com"))

return "PROXY 183.224.1.56:80";


return "DIRECT";
}

發表人:  aaaa007cn [ 2014-08-23, 18:28 ]
文章主題 :  Re: 請問proxy.pac的寫法

http://en.wikipedia.org/wiki/Proxy_auto-config
給了一些有用的鏈接
比如 http://findproxyforurl.com/pac-functions/
引言回覆:

dnsDomainIs

Evaluates hostnames and returns true if hostnames match. Used mainly to match and exception individual hostnames.
代碼:
// If the hostname matches or contains google.com (e.g. maps.google.com, www.google.com),
// send direct to the Internet.

if (dnsDomainIs(host, ".google.com"))
   return "DIRECT";


針對原PO的那個例子
代碼:
function FindProxyForURL(url, host) {
    if (dnsDomainIs(host, ".xiami.co") || dnsDomainIs(host, ".xiami.com")) {
        return "PROXY 183.224.1.56:80";
    }
    return "DIRECT";
}

1 頁 (共 1 頁) 所有顯示的時間為 UTC + 8 小時
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/