proxy.pac files, Mozilla (Firefox & Thunderbird) and Vista or Windows 7

I’ve found a problem with Mozilla based products and proxy settings.

To automatically configure a proxy for use by Internet browsers, you can use a file called “proxy.pac“. This is a JavaScript function that is loaded into the browser when it starts and redirects requests via a proxy where required.

All of the descriptions for this file you will find on the Internet will provide the following example of checking your current IP address. This is used for laptops where the IP address will change depending on where you are. You can check when the laptop is on the corporate network and redirect requests via the corporate proxy as needed:

if ( isInNet(myIpAddress(), "10.10.10.0", "255.255.255.0") ) {
  alert("Corporate address & proxy");
  return "PROXY 10.10.10.240";
 }

Well, this does not work for Mozilla based applications (for example Firefox and Thunderbird) if you are using Microsoft Vista or Windows 7.

That is because, under those operating systems, the internal function myIpAddress() does not return an IPv4 address as expected (e.g. 10.10.10.5) but an IPv6 address instead (e.g something longer with lots of “:”).

In order to make your proxy.pac file work with both IE and Mozilla, use something like:

if (isInNet(myIpAddress(), "10.97.100.0", "255.255.255.0") ||
            shExpMatch(myIpAddress(), "fe80::b892:6a74:9635:*") ) {
  alert("Corporate address & proxy");
  return "PROXY 10.61.9.200:8080; DIRECT;";
 }

You can discover your IPv6 address in several ways but the trusty command line “ipconfig /all” shows you everything you need.

See also this discussion on the Mozilla support forums: proxy.pac myIpAddress() returns incorrect format?


Del.icio.us : , , ,
Technorati : , , ,
Diigo Tag Search : , , ,

  • Pingback: URL()

  • Depp Jones

    You could also try to set network.dns.disableIPv6 to true in about:config