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