Skip to content

Instantly share code, notes, and snippets.

@nosmo
Last active November 13, 2025 07:29
Show Gist options
  • Select an option

  • Save nosmo/716e6eef47131fa8841d10805e46d95e to your computer and use it in GitHub Desktop.

Select an option

Save nosmo/716e6eef47131fa8841d10805e46d95e to your computer and use it in GitHub Desktop.
How to pre-configure a proxy in Firefox from the command-line

Firefox does not obey the HTTP_PROXY/http_proxy environment variables on Linux without additional plugins. There's no way to explicitly configure Firefox to use a proxy via the command-line, so workarounds are needed.

My usecase is setting up a throwaway Firefox instance in a container using an SSH SOCKS proxy for interactive browsing of restricted web interfaces.

To do the setup, create a new profile via:

mkdir /tmp/firefox_profile
echo 'user_pref("network.proxy.socks", "host.docker.internal");' >> /tmp/firefox_profile/prefs.js
echo 'user_pref("network.proxy.socks_port", 9000);' >> /tmp/firefox_profile/prefs.js
echo 'user_pref("network.proxy.type", 1);' >> /tmp/firefox_profile/prefs.js

Where host.docker.internal is the proxy hostname and 9000 is the port. For a http or https proxy, change socks and socks_port to http and http_port. network.proxy.type does not need to be changed, it simply instructs Firefox to use a manually defined proxy.

And then invoke Firefox using firefox --profile /tmp/firefox_profile. Firefox starts up, loads the existing proxy configuration and writes the rest of Firefox's profile configuration to the same directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment