Skip to content

Running Multiple Services

Sam Bent edited this page Nov 17, 2026 · 8 revisions

Running Multiple Services

One HiddenForge container can host several independent .onion addresses at once: a public site, a private admin panel, a file drop, each with its own address and its own key. This page shows how.

The idea

Every environment variable ending in _TOR_SERVICE_HOSTS becomes its own hidden service, with its own .onion. Add more variables, get more services. Each one is independent: knowing one address tells an outsider nothing about the others.

Example: a public site and a private panel

Start from the shipped docker-compose.yml (see Quickstart) and keep every setting on the tor service as it is. Change only its environment and depends_on, and add one backend per site:

services:
  tor:
    # ...everything else exactly as shipped...
    environment:
      BLOG_TOR_SERVICE_HOSTS:  "80:blog:80"
      ADMIN_TOR_SERVICE_HOSTS: "80:admin:8080"
    depends_on:
      - blog
      - admin

  blog:
    image: nginx:alpine
    # ...the same hardening as the shipped `web` service...
    networks:
      - tor-internal

  admin:
    image: your-admin-app:latest
    # ...the same hardening as the shipped `web` service...
    networks:
      - tor-internal

Remove the shipped web service if nothing uses it any more.

You now have two .onion addresses, one per service folder:

hiddenforge show --keys ./tor-keys --name blog
hiddenforge show --keys ./tor-keys --name admin

Without --name, show prints every service it can find in the key folder; if it cannot list them, it asks for --name. The container can also be asked directly:

docker compose exec tor hiddenforge show --name blog

The folder name comes from the variable prefix, lowercased with underscores turned into hyphens. BLOG becomes blog, and MY_ADMIN would become my-admin.

Multiple ports on one service

You can also expose more than one port for a single service by separating mappings with commas:

WEB_TOR_SERVICE_HOSTS: "80:web:80,443:web:443"

Both ports belong to the same .onion address.

Generating the same thing with setup

hiddenforge setup can write this configuration for you. --service is repeatable and takes name:onion_port:host:port:

hiddenforge setup --service blog:80:blog:80 --service admin:80:admin:8080 --out ./deploy

Mappings that share a name are joined into one variable, so --service blog:80:blog:80 --service blog:443:blog:443 gives BLOG_TOR_SERVICE_HOSTS: "80:blog:80,443:blog:443". --services takes the same entries comma-separated. See The hiddenforge CLI.

Reading the mapping format

Each mapping is onion_port:backend_name:backend_port. There is a two-part shorthand, onion_port:backend_port, but it points at 127.0.0.1 inside the tor container itself, which is only useful if your app runs in the same container. That is not the normal setup here. For the standard "separate backend container" layout, always use the three-part form with the backend's service name.

If one mapping is wrong

HiddenForge is forgiving about mistakes. A single bad mapping (an invalid port, a malformed entry) is skipped, and the rest of your services still come up. An invalid service name skips just that one variable. A backend name that doesn't resolve yet is skipped too, and added automatically once it resolves. The container keeps running either way. If a service is missing, hiddenforge status --json lists every skipped mapping and why under dropped_mappings (container logging is off by design, so the logs won't tell you).

Keep the security settings on every backend

Per-service options use the service name. hiddenforge client-auth add --keys ./tor-keys --name admin --client alice restricts only the admin address to authorized clients, and leaves blog public.

Each backend you add should follow the same pattern as the example: on tor-internal only, no ports: mapping, read_only with small noexec,nosuid,nodev tmpfs mounts for anything it must write. A backend with a published port or an internet route is the one mistake that undoes the whole design. See OPSEC: Mistakes That Deanonymize You.

Clone this wiki locally