Automatic proxy switching in Firefox

After each installation of Firefox, I always installed the SwitchProxy extension which I found quite useful, as I sometimes am connected directly to the internet, and at other times, when connected through VPN, I am using a proxy. The SwitchProxy extension allows me to choose the correct proxy in a menu bar, so I don’t have to go to “Tools->Options->General->Connection Settings” and choose the correct proxy settings.

The problem with that extension, as with all extensions, is that you typically have to reinstall an up-to-date version after a new release of Firefox is out. So I tried to find more information about the syntax and capabilities of the automatic proxy configuration file and found quite useful information in Wikipedia and at Mozilla. Although most documents only describe the http:// URL, it’s (of course) also possible to use the file:// URL for the proxy config file. Might be useful if you do not have write access to a web server…

Let the browser find your proxy

Just create a local file /etc/proxy.pac, /home/<username>/cfg/proxy.pac, or C:\cfg\proxy.pac (or whatever path you like) in your current operating system environment, and replace the string with your specific proxy host name and port:

function FindProxyForURL(url, host) {
return "PROXY; DIRECT";

Then, enter the following in your Firefox proxy settings, in the line Automatic Proxy Configuration URL:


or, in Windows:


and click “OK”. That’s all.

BTW – Lots of examples for automatic proxy config files can be found when searching the web for the string “FindProxyForURL”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: