Local .pac file in Firefox

8,647

Solution 1

Got it.

File URLs do not seem to be a problem as of Firefox 57.0.2.

Upon examining my PAC file, I spotted a syntax error (missing closing parenthesis in an expression). After I fixed that and reloaded the PAC file (with the file:/// version of the URL), it seemed to work. I can now access the site which requires the proxy.

What I haven’t figured out yet is whether Firefox logs an error message somewhere—I spotted the syntax error by coincidence.

Solution 2

Assuming that your PAC is correctly written then the reason it's not working with the specific sites in the PAC is because Firefox is not parsing it.

[update] The original answer incorrectly asserted that paths for PAC files did not work. Whilst this might have been true for older versions of Firefox, this is now incorrect.

One possible solution is to run an extremely small web-server on your computer and host the pac file using that. This thread over at Stack Overflow seems to recommend Mongoose.

If you do that then you can set the URL in Firefox to http://127.0.0.1/proxy.pac and it should load just fine.

Share:
8,647

Related videos on Youtube

user149408
Author by

user149408

Updated on September 18, 2022

Comments

  • user149408
    user149408 over 1 year

    I use Firefox on Windows and need a somewhat exotic proxy configuration, as I am on a network from which i must go through a proxy to reach certain sites. Some sites will not be reachable through the proxy server, and most public web sites will work, albeit performance will be poor.

    Therefore, I need the inverse of the usual “connect directly to X, Y and Z, use the proxy for all others”—what I need is “use the proxy for X, Y and Z, connect directly to all others”.

    To this end, I have created a .pac file with the desired rules. In Firefox’s proxy config, I have entered the URL to that file as a proxy auto-config URL. The path looks like this: file:///c:/Users/myself/Application%20Data/proxy.pac.

    When I try it out, I can browse the Internet but cannot connect to sites which require going through the proxy server.

    I have tried dropping the file:/// prefix, which gives the same results.

    If I change the prefix to file://, Firefox will add the missing slash. If I replace %20 with a space character, Firefox will escape it again. The Reload button for the URL is available (it is grayed out if I change the URL to point to a nonexistent file). So apparently Firefox can find the file but it does not have the desired effect.

    What is wrong here, or what can I try to figure out why this doesn’t work?

    • iMath
      iMath almost 3 years
      In Internet Explorer 11, the WinINET team has disabled WinINET’s support for file:// based scripts to promote interoperability across network stacks. Corporations are advised to instead host their proxy configuration scripts on a HTTP or HTTPS server superuser.com/a/1569042/392629
  • user149408
    user149408 over 6 years
    Just spotted a syntax error in the PAC, now I got it to work. file:/// is definitely supported as of FF 57.0.2.
  • Richard
    Richard over 6 years
    Glad to hear! Apologies for being out of date.
  • Richard
    Richard over 6 years
    There are some tools out there (apologies, I cannot search) both command line based and web-based which can validate a PAC file for you.
  • selurvedu
    selurvedu almost 5 years
    @Richard, I use pactester from github.com/pacparser/pacparser