ragnaroks
V2EX  ›  问与答

PAC 文件到底怎么写?

  •  
  •   ragnaroks · Sep 8, 2018 · 2896 views
    This topic created in 2830 days ago, the information mentioned may be changed or developed.
    FindProxyForURL(url,host){
        var steam_domains=['steamstatic.com','steamcommunity-a.akamaihd.net','steamuserimages-a.akamaihd.net','steamstore-a.akamaihd.net'];
        for(var i=0;i<steam_domains.length;i++){
            if(host.indexOf(steam_domains[i])>-1){return "PROXY 127.0.0.1:31281; DIRECT;";}
        }
        return 'DIRECT';
    }
    

    windows10 系统设置->网络和 Internet->代理->自动设置脚本:开,
    填入"http://localhost:3389/index.pac",
    抓包发现确实该文件被读取了,但是 chrome 和 firefox 都没有使用代理,无效.

    firefox:选项->网络代理->自动代理配置的 URL,
    填入"http://localhost:3389/index.pac",
    抓包发现确实该文件被读取了,但是 firefox 没有使用代理,无效.

    chrome:

    • 同直接系统设置,无效.
    • 安装 switchyomega,并新建 pac 情景模式,填入"http://localhost:3389/index.pac",有效.

    虚拟机 win7 也试过了,一模一样的情况,也试过直接就 return proxy,依然只有 chrome+拓展才有效

    1 replies    2018-09-08 21:00:13 +08:00
    X-Force
        1
    X-Force  
       Sep 8, 2018
    Windows 下需要在 header 设置正确的 Content-Type,否则各种神奇问题。
    Content-Type: application/x-ns-proxy-autoconfig
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4103 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 00:55 · PVG 08:55 · LAX 17:55 · JFK 20:55
    ♥ Do have faith in what you're doing.