• Tutorial: How to Load a PAC File Directly from Disk in Firefox (No Web Server Needed)

    From Marion@mariond@facts.com to alt.comp.software.firefox,alt.comp.os.windows-10,alt.os.linux,alt.comp.os.windows-11 on Thu Oct 30 00:19:12 2025
    From Newsgroup: alt.os.linux

    Tutorial:
    How to Load a PAC File Directly from Disk in Firefox
    (without needing a web server such as "mongoose" to serve it)

    Firefox is one of the few browsers that allows PAC files to be loaded
    directly from disk using a typical file:/// URL instead of a web server.

    1. Firefox:Tools > Settings > Network settings > [Settings...]
    2. In the "Connection Settings" dialog
    Select "Automatic proxy configuration URL"
    3. Paste the path to your PAC file, e.g.,
    file:///C:/app/network/proxy/proxy.pac
    4. Press [OK] to save

    This method works on Windows, Linux, and macOS.
    Just adjust the file:/// path format for your operating system.
    A. LINUX: file:///home/username/proxy/proxy.pac
    B. macOS: file:///Users/username/proxy/proxy.pac
    C. Windows: file:///C:/Users/username/proxy/proxy.pac

    After setting Firefox to read the PAC file as shown above, we can then test
    by visiting about:networking#dns (set "Autorefresh every 3 seconds" & then
    we can visit a site that should go through the proxy to watch what happens.

    We can also check our IP on a site which reports what it sees in Firefox:
    <https://ifconfig.me>
    <https://ipleak.net>
    <https://icanhazip.com>

    Probably better though to check using a dedicated proxy testing site which
    can detect whether we're behind a proxy & sometimes even show the type.
    <https://www.whatismyproxy.com/>
    <https://browserleaks.com/proxy>
    <https://www.lagado.com/tools/proxy-test>

    If we want to test outside the browser, we can use curl with one of the PAC testers above or we can manually specify the proxy in the curl command.
    curl --proxy socks5h://127.0.0.1:1080 https://ifconfig.me
    If we only configured the PAC file inside Firefox, then only Firefox will follow the specified PAC (Proxy Auto Config) rules.

    Not curl.

    Note that if we are configuring the proxy PAC file system-wide in Windows,
    we'd likely need to serve it over HTTP (e.g., with Mongoose). In that case, we'd set Firefox to "Use system proxy settings" instead of the filespec.

    But for just Firefox alone, the file:/// approach works just fine.

    Below is an example PAC file that I use for my specific needs, which I've
    added comments to so that anyone else can pick it up for their own re-use.

    ---< cut here for proxy.pac >---
    /*
    proxy.pac C:\app\network\proxy\proxy.pac (20250902)
    file:///C:/app/network/proxy/proxy.pac (for Firefox)
    This is version 1.4
    Selectively bypass proxy for sites sensitive to IP shifts:
    - Google services (search, mail, etc.)
    - Amazon (especially the Amazon Vine Voice program)
    - Specific Microsoft domains (Copilot)
    All other traffic routed through local SOCKS proxy at 127.0.0.1:1080
    - Including Windows Update

    Useful for split-tunnel setups where trusted domains go direct
    but everything else is encrypted via Psiphon SOCKS5 proxy.

    If needed, test PAC web access and fundamental logic with:
    - https://pactester.brdbnt.com/
    - https://github.com/termsl/WPADChecker
    - curl http://127.0.0.1/proxy.pac

    v1.0 20250902(added Amazon Vine Voice https://amazon.com/vine/about)
    v1.1 20250910(added Google Gmail but I need to add it to Thunderbird)
    v1.2 20250918(added Microsoft sites for practice adding domains)
    v1.3 20251016(removed Microsoft domains for Windows-Update reasons)
    v1.4 20251016(rewrote to eliminate Windows-Update altogether)
    */

    function FindProxyForURL(url, host) {
    // Bypass Gmail & Google
    if (shExpMatch(host, "*.google.com") ||
    shExpMatch(host, "*.gmail.com") ||
    shExpMatch(host, "mail.google.com")) {
    return "DIRECT";
    }

    // Bypass Amazon Vine <https://amazon.com/vine/about>
    if (shExpMatch(host, "*.amazon.com") ||
    shExpMatch(host, "amazon.com")) {
    return "DIRECT";
    }

    // Keep Copilot direct for stability
    if (shExpMatch(host, "*.copilot.microsoft.com")) {
    return "DIRECT";
    }

    // All other traffic, including Microsoft Update, Bing, etc. ? proxy
    return "SOCKS 127.0.0.1:1080";
    }
    ---< cut here for proxy.pac >---

    Another way to test the proxy from within Firefox is:
    a. Go to <about:blank>
    b. Press Ctrl+Shift+K to open the web console for that page
    c. Paste this
    fetch("https://ifconfig.me/ip")
    .then(r => r.text())
    .then(ip => console.log("Your current IP is:", ip));
    d. You should now see your current external IP printed in the console.

    A more permissive endpoint would be:
    fetch("https://api.ipify.org?format=text")
    .then(r => r.text())
    .then(ip => console.log("Your current IP is:", ip));

    What I see, for example, when I test this out for you, is the following:
    Your current IP is: 172.236.227.197

    Many thanks to Andy Burns who was the first person in my life to mention
    PAC files, which I looked up and found out from that how useful they are.
    --
    Helping others & learning from them is what this Usenet ng is all about.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Marion@mariond@facts.com to alt.comp.software.firefox,alt.comp.os.windows-10,alt.os.linux,alt.comp.os.windows-11 on Thu Oct 30 12:48:06 2025
    From Newsgroup: alt.os.linux

    Marion wrote:
    How to Load a PAC File Directly from Disk in Firefox
    (without needing a web server such as "mongoose" to serve it)

    UPDATE:

    Given a proxy file in location C:\app\network\proxy\proxy.pac, Firefox can load it using the urlspec as shown in the prior original post in this thread.

    The other way to load a PAC file, which Firefox can also use, is via a self-hosted likely small-footprint local web server, such as mongoose.exe.

    In that case, the urlspec for Firefox to load the PAC file then changes
    FROM: file:///C:/app/network/proxy/proxy.pac
    TO: http://127.0.0.1/proxy.pac

    To set that up, the Firefox steps would be only slightly different.
    1. Firefox:Tools > Settings > Network settings > [Settings...]
    2. In the "Connection Settings" dialog
    Select "Automatic proxy configuration URL"
    3. Paste the path to your PAC file, e.g.,
    http://127.0.0.1/proxy.pac
    4. Press [OK] to save

    This method has the advantage that Firefox can use a different proxy redirection than the rest of the PC platform uses, or it can be the same.

    Of course, it means you need to install & set up a local web server, e.g.,
    this launchmongoose.vbs script is what I use on my Windows 10 PC for that.

    ' ============================================
    ' launchmongoose.vbs 20250916 version 1.0
    ' This is version 1p5
    ' ============================================
    ' Version History:
    ' 1p0 20250916 Initial silent launch
    ' 1p1 20250916 Added process check and logging
    ' 1p2 20250916 Fixed duplicate End If error
    ' 1p3 20250916 Added version header block, cleaned structure
    ' 1p4 20250916 Removed unconditional launch
    ' Now launches only if not running
    ' 1p5 20250916 Updated launch command to set working directory
    ' ============================================
    ' Serves C:\app\network\proxy\proxy.pac as http & https
    ' Launch using: cscript //nologo launchmongoose.vbs
    ' Test using: curl http://127.0.0.1/proxy.pac
    ' Testing using: type mongoose.log
    ' Or just use: tasklist /fi "imagename eq mongoose.exe"
    ' Kill using: taskkill /f /im mongoose.exe
    ' Test this script: cscript //nologo "C:\app\network\proxy\launchmongoose.vbs"
    ' ==============================
    ' Added in version 1.1
    ' ==============================
    ' Features:
    ' - Skips launch if mongoose.exe is already running
    ' - Logs launch attempts to mongoose.log
    ' ==============================
    ' Fixed in version 1.2
    ' ==============================
    ' got rid of errors
    ' ==============================
    ' Improved in version 1.4
    ' ==============================
    ' Removed unconditional launch from version 1.0
    ' Due to error: PAC file not available.
    ' Added explicit path to Mongoose launch
    ' WshShell.Run """C:\app\network\proxy\mongoose.exe"" -l http://127.0.0.1:80 -d C:\app\network\proxy", 0, False
    ' This ensures proxy.pac is served correctly regardless of current working directory
    ' ==============================

    Set WshShell = CreateObject("WScript.Shell")

    Set execCheck = WshShell.Exec("cmd /c tasklist /fi ""imagename eq mongoose.exe"" | find /i ""mongoose.exe""")
    If execCheck.StdOut.ReadAll = "" Then
    ' Mongoose is not running, launch silently
    WshShell.Run """C:\app\network\proxy\mongoose.exe"" -l http://127.0.0.1:80 -d C:\app\network\proxy", 0, False

    ' Log the launch
    WshShell.Run """cmd.exe"" /c echo [" & Date & " " & Time & "] Mongoose launched >> C:\app\network\proxy\mongoose.log", 0, False
    Else
    ' Mongoose is already running, skip launch
    WshShell.Run """cmd.exe"" /c echo [" & Date & " " & Time & "] Mongoose already running >> C:\app\network\proxy\mongoose.log", 0, False
    End If
    --
    Posted so that others can use Firefox to serve a PAC file of their choosing. --- Synchronet 3.21a-Linux NewsLink 1.2