Configuring Firefox to use a proxy from the command line
Firefox just can't do the standard thing and use environment variables (though to be honest this is partly justified as the standard thing doesn't allow for proxy autoconfiguration files). The preferences for static proxies are
user_pref("network.proxy.http", "wwwproxy.example.com");
user_pref("network.proxy.http_port", 3128);
user_pref("network.proxy.type", 1);
There's a Firefox extension to use $http_proxy
and similar environment variables: Environment Proxy.
Recent versions of Firefox supposedly use the usual environment variables by default, or if the proxy type preference is explicitly set to 5 (“Use system proxy settings”), but it doesn't work for me with the version in Ubuntu 10.04.
user_pref("network.proxy.type", 5);
You say 'proxy', but your examples indicate you probably mean 'HTTP proxy' specifically. However, if you also have access to a SOCKS proxy, which does not forbid HTTP traffic, you could use the tsocks
tool:
tsocks firefox
once you have configured /etc/tsocks.conf
suitably.
According to a listing of commandline options there is no explizit option for a proxy. As you found out also neither http_proxy
nor something alike works. I would suggest to first create a profile:
firefox -CreateProfile foo
Next you can use sed
or whatever tool you like to write user_pref("network.proxy.http", "YOUR_PROXY"); user_pref("network.proxy.http_port", PORT);
to prefs.js
. Now Firefox should work fine with those proxies.