V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
ragnaroks
V2EX  ›  问与答

PAC 文件到底怎么写?

  •  
  •   ragnaroks · 2018-09-08 17:39:38 +08:00 · 2477 次点击
    这是一个创建于 2094 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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 条回复    2018-09-08 21:00:13 +08:00
    X-Force
        1
    X-Force  
       2018-09-08 21:00:13 +08:00
    Windows 下需要在 header 设置正确的 Content-Type,否则各种神奇问题。
    Content-Type: application/x-ns-proxy-autoconfig
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2656 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:04 · PVG 22:04 · LAX 07:04 · JFK 10:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.