Self-Host a Secure Remote Firefox Browser with Docker

Run Firefox in a Docker container on Railway or your own server, and use it from any browser behind a login page, with a saved profile.

A remote browser runs on a server instead of your own machine, and you use it from a normal browser tab. That's useful for a few things:

  • Opening suspicious links without them touching your device.
  • Keeping a separate, disposable browsing environment for privacy.
  • Testing sites from another location.
  • Keeping a session running when your laptop is closed.

Running Firefox in a Docker container makes the setup quick, and you can throw the container away and start again whenever you like. It isn't an anonymiser, though; the FAQ at the end explains why.

This post uses the jlesage/firefox image, an open-source image that streams Firefox to your browser through a built-in web interface and gets regular releases. To run Firefox in Docker with it:

  1. Set a username and password, so the browser isn't open to anyone who finds it.
  2. Mount a volume at /config to keep your Firefox profile.
  3. Run the image on Railway, or on any Linux server with Docker.
  4. Open port 5800 in your browser and sign in.

Protect Your Remote Browser with a Login

A remote browser on a public URL with no password is an open proxy: anyone who finds it can browse from your server, at your expense and from your server's IP address. The jlesage image has a built-in login page, which you turn on with these environment variables:

VariableValue
WEB_AUTHENTICATION1 turns on the login page
WEB_AUTHENTICATION_USERNAMEYour username
WEB_AUTHENTICATION_PASSWORDA long, random password from your password manager
KEEP_APP_RUNNING1 restarts Firefox automatically if it closes or crashes

After you sign in, the image keeps you logged in for 24 hours by default (WEB_AUTHENTICATION_TOKEN_VALIDITY_TIME), or until the container restarts.

The image also stores Firefox's profile (bookmarks, extensions, cookies and settings) in /config. Mount a volume there, or everything resets each time the container restarts. If you want a fresh, disposable browser every time, leave the volume out.

Run Firefox in Docker on Railway

Railway can run a public Docker image directly, without a repo:

  1. Create a new project, choose Docker Image, and enter jlesage/firefox:v26.11.1.
  2. In the service's Variables, add the four variables from the table above, plus WEB_AUTHENTICATION_ALLOW_INSECURE=1 (explained below).
  3. Add a volume to the service, mounted at /config.
  4. Under Settings > Networking, click Generate Domain and choose port 5800, the image's web interface. The image also listens on 5900 for VNC clients, which you don't need.

Open the domain, sign in, and Firefox appears in the tab.

Firefox running in a Docker container, opened in a web browser
Remote Firefox in a browser tab

The WEB_AUTHENTICATION_ALLOW_INSECURE variable is needed because the image expects its login page to be served over HTTPS. On Railway, HTTPS is handled at Railway's edge, which then forwards plain HTTP to your container inside Railway's network. The image's documentation describes this reverse proxy setup and allows the setting for it. Your browser still connects over HTTPS. Don't add a TCP proxy for port 5800 in Railway, because that would expose the container's plain HTTP port directly. Firefox needs a fair amount of memory, so if tabs crash or the page stays blank, give the service more RAM.

Run Firefox with Docker Run or Docker Compose

On any Linux server with Docker, such as a DigitalOcean droplet, the same setup is one command. Here the container serves its own HTTPS, so SECURE_CONNECTION=1 replaces the insecure setting:

docker run -d \
    --name=firefox \
    --restart unless-stopped \
    -p 5800:5800 \
    -v /docker/appdata/firefox:/config:rw \
    -e SECURE_CONNECTION=1 \
    -e WEB_AUTHENTICATION=1 \
    -e WEB_AUTHENTICATION_USERNAME=yourname \
    -e WEB_AUTHENTICATION_PASSWORD='use-a-long-random-password' \
    -e KEEP_APP_RUNNING=1 \
    jlesage/firefox:v26.11.1

The same configuration as a docker-compose.yml file, if you prefer Docker Compose:

services:
  firefox:
    image: jlesage/firefox:v26.11.1
    container_name: firefox
    restart: unless-stopped
    ports:
      - "5800:5800"
    volumes:
      - /docker/appdata/firefox:/config:rw
    environment:
      SECURE_CONNECTION: "1"
      WEB_AUTHENTICATION: "1"
      WEB_AUTHENTICATION_USERNAME: yourname
      WEB_AUTHENTICATION_PASSWORD: use-a-long-random-password
      KEEP_APP_RUNNING: "1"

Start it with docker compose up -d, then open https://your-server-ip:5800. The container generates a self-signed certificate, so your browser shows a warning the first time. To avoid it, put your own certificate files in /config/certs, or put the container behind a reverse proxy such as Caddy that gets a certificate for your domain.

For tighter security, don't expose port 5800 to the internet at all. If the server is on a private Tailscale network, only your own devices can reach the browser.

Keep the Firefox Docker Image Up to Date

A browser is exposed to every website you visit, so keep it patched. The image's maintainer publishes new versions regularly, tagged by date (for example v26.11.1 is the first release of November 2026). Pin a specific tag as shown above, so updates happen when you choose, and check the releases page every few weeks. To update, change the tag and redeploy. Your profile stays in /config.

Frequently Asked Questions

Is a remote browser more private than my own browser? It keeps tracking, downloads and malware away from your device, and websites see the server's IP address instead of your home one. But it isn't anonymous: your accounts and browsing habits still identify you, your hosting provider can see the server's traffic, and some sites block traffic from data centre IP ranges.

What port does jlesage/firefox use? Port 5800 for the web interface you open in a browser, and port 5900 for VNC clients. You only need 5800.

How do I set a password for jlesage/firefox? Set WEB_AUTHENTICATION=1, WEB_AUTHENTICATION_USERNAME and WEB_AUTHENTICATION_PASSWORD. For several users, or to avoid keeping the password in an environment variable, the image can also read bcrypt-hashed passwords from /config/webauth-htpasswd, which you manage with its webauth-user command.

Can I use Chromium instead of Firefox? Yes. The same maintainer publishes images for other desktop apps, and LinuxServer.io publishes browser images too. If you want a full desktop with several apps, see my post on LinuxServer Webtop.

Why does Firefox crash or show a blank screen? Usually the container is short of memory, so give it more RAM. On older Docker versions, the image's documentation also lists a system call (membarrier) that Docker must allow for Firefox to run reliably.

Subscribe to alphasec

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe