> ## Content Index
> Fetch the complete content index at: https://trendboxgeek.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Headplane Headscale OIDC Login and Browser SSH Setup Guide
- URL: https://trendboxgeek.com/blog/headplane-oidc/
- Published: 2026-10-29T04:55:45.000Z
- Updated: 2026-10-29T04:55:45.000Z
- Author: Pankajbhai Chavda
- Tags: #blog-col

I have been using Headscale for some time, because I do not want my private network tied to Tailscale's SaaS device limits or pricing tiers. Headscale itself is rock solid, but doing every single task from the command line gets old fast. If you have only three servers, checking which nodes are online or offline, editing a big acl.hujson file over SSH, or generating pre-auth keys by hand is fine. Once your network grows, you need a dashboard.

A recent issue of [Self-Host Weekly](https://selfh.st/weekly/2026-10-09/?ref=trendboxgeek.com) pointed me back to [Headplane](https://headplane.net/?ref=trendboxgeek.com), a web interface built specially for Headscale. Earlier versions of Headplane were basic node viewers, but its recent version includes two features that are truly important to me: OpenID Connect (OIDC) user linking and Browser SSH.

The idea is simple: log into Headplane with your SSO account, click the SSH button next to any Linux server in your Tailnet, and get a terminal right in your browser tab without opening port 22 on your firewall.

In practice, I encountered several complex issues while setting up `Browser SSH` on a new Ubuntu 26.04 LTS server (`192.168.100.77`). These include WebSocket upgrades, port 80 fetch errors, DERP relay quirks, and even a weird Chrome GPU rendering bug where the terminal stayed pitch black while the bash session was alive in the background.

Here is the exact setup that worked on my server, along with how I fixed each of those issues.

## Before You Start: Check Your Headscale Version

Do not blindly pull headscale:latest or the newest beta tag without checking the version number first.

Use Headscale v0.28.0 (or 0.29.2+). Headplane Agent needs tag-only pre-auth keys, which require Headscale 0.28 or newer.

Avoid Headscale 0.29.0 beta through 0.29.1\. Whenever you run a CLI command on v0.28.0, Headscale shows you a warning that 0.29.0-beta.4 is available. But ignore it. The early 0.29 builds have a routing bug on `/ts2021` that rejects browser WebSocket connections with 405 Method Not Allowed, which completely breaks Browser SSH.

**Note:** Before running any command, replace `192.168.100.77` with your server IP or domain wherever you see it.

## Install Docker and Create the Directory Structure

On my Ubuntu 26.04 server (`boxgeek` at `192.168.100.77`), I installed Docker and Compose from the standard Ubuntu repositories.

```bash
sudo apt update && sudo apt install -y docker.io docker-compose-v2
```

Next, create a clean directory under `/opt/headscale-stack` to hold the configs and persistent data for Headscale, Headplane, Caddy, and Dex (I am using Dex here as a lightweight local OIDC server to test the full flow, though you can swap in Authentik, Pocket ID, or Keycloak).

sudo mkdir -p /opt/headscale-stack/{headscale/{config,data},headplane/data/agent,dex,caddy/data}
sudo chown -R $USER:$USER /opt/headscale-stack
cd /opt/headscale-stack

## Configure Headscale and SSH ACLs

We are going to place Caddy in front of both Headscale and Headplane on port 443, while Headscale itself will listen internally on port 8085.

Run these commands to create `/opt/headscale-stack/headscale/config/config.yaml`, `dns_records.json`, and `acl.hujson` (replace `192.168.100.77` with your server's IP or domain).

cat << 'EOF' > /opt/headscale-stack/headscale/config/config.yaml
server_url: https://192.168.100.77
listen_addr: 0.0.0.0:8085
metrics_listen_addr: 0.0.0.0:9090
grpc_listen_addr: 0.0.0.0:50443
grpc_allow_insecure: true

noise:
  private_key_path: /var/lib/headscale/noise_private.key

prefixes:
  v4: 100.64.0.0/10
  v6: fd7a:115c:a1e0::/48
  allocation: sequential

derp:
  server:
    enabled: false
    region_id: 999
    region_code: "headscale"
    region_name: "Headscale Embedded DERP"
    stun_listen_addr: "0.0.0.0:3478"
    private_key_path: /var/lib/headscale/derp_server_private.key
    automatically_add_embedded_derp_region: true
    ipv4: 192.168.100.77
  urls:
    - https://controlplane.tailscale.com/derpmap/default
  auto_update_enabled: true
  update_frequency: 24h

disable_check_updates: false
ephemeral_node_inactivity_timeout: 30m

database:
  type: sqlite
  sqlite:
    path: /var/lib/headscale/db.sqlite
    write_ahead_log: true

policy:
  mode: file
  path: /etc/headscale/acl.hujson

dns:
  magic_dns: true
  base_domain: tailnet.internal
  override_local_dns: false
  nameservers:
    global:
      - 1.1.1.1
      - 8.8.8.8
  extra_records_path: /etc/headscale/dns_records.json

unix_socket: /var/run/headscale/headscale.sock
unix_socket_permission: "0770"
EOF
echo "[]" > /opt/headscale-stack/headscale/config/dns_records.json
cat << 'EOF' > /opt/headscale-stack/headscale/config/acl.hujson
{
  "acls": [
    {
      "action": "accept",
      "src": ["*"],
      "dst": ["*:*"]
    }
  ],
  "ssh": [
    {
      "action": "accept",
      "src": ["autogroup:member"],
      "dst": ["autogroup:self"],
      "users": ["autogroup:nonroot", "root"]
    }
  ]
}
EOF

**Two important details here:**

1. **Leave `derp.server.enabled: false` unless you have real public TLS certs.** When I first enabled Headscale's embedded DERP server without trusted TLS certificates, `tailscale status` threw a health warning (`Tailscale could not connect to the 'Headscale Embedded DERP' relay server`) because region `999` was advertising plain HTTP. Leaving the embedded DERP disabled tells both your servers and the browser WASM client to use Tailscale's official HTTPS DERP relays (`urls: ` `https://controlplane.tailscale.com/derpmap/default `), which work out of the box.
2. **Never put `"users": ["*"]` in your Headscale SSH ACL block.** Several Tailscale client versions treat `"*"` as a literal Linux username instead of a wildcard and drop the connection with `failed to look up local user *`. Always use `"autogroup:nonroot"` and `"root"`, or list your Linux usernames explicitly.

## Set Up OIDC, Caddy, and Docker Compose

At first, I tried running Headplane on `http://<server-ip>:3000` and Headscale on `http://<server-ip>:8080` with CORS headers in between. That failed completely.

When I opened the SSH window, it stayed on **Joining Tailnet....** forever. Looking at the Caddy access logs showed why: the browser's WASM client hit GET /key?v=125 twenty times in a row, got 200 OK every time, and never once sent the `/ts2021` WebSocket upgrade request. Tailscale's browser client expects an `https://` control URL on port 443 (`wss://`).

Then, once I moved everything to `https://`, clicking SSH threw an Unexpected Server Error box. Checking `sudo docker logs headplane` showed:

```text
[TypeError: fetch failed] {
  [cause]: Error: connect ECONNREFUSED 192.168.100.77:80
}
```

Even when `server_url` is `https://`, Headplane's backend makes a plain HTTP call to port 80 on the control host during the SSH page setup.

To fix both issues, I configured Caddy to serve `/admin*` (Headplane) and `/` (Headscale) from the same address on HTTPS (**443**) and plain HTTP (**80**), plus port **8080** for local Linux nodes joining over LAN. Running both on the same address avoids CORS errors completely, and Caddy forwards the `Upgrade: websocket` and `Sec-WebSocket-Protocol: derp` headers on its own.

Run this block to create the Dex OIDC configuration (`admin@example.com` / password `password`), the `Caddyfile`, and `compose.yaml`, then start `headscale`, `dex`, and `caddy`.

cat << 'EOF' > /opt/headscale-stack/dex/config.yaml
issuer: http://192.168.100.77:5556/dex
storage:
  type: sqlite3
  config:
    file: /var/dex/dex.db
web:
  http: 0.0.0.0:5556
enablePasswordDB: true
staticPasswords:
  - email: "admin@example.com"
    hash: "$2a$10$2b2cU8CPhOTaGrs1HRQuAueS7JTT5ZHsHSzYiFPm1leZck7Mc8T4W"
    username: "admin"
    userID: "08a8684b-db88-4b73-90a9-3cd1661f5466"
staticClients:
  - id: headplane-oidc
    redirectURIs:
      - 'https://192.168.100.77/admin/oidc/callback'
      - 'http://192.168.100.77:8080/oidc/callback'
    name: 'Headplane & Headscale SSO'
    secret: headplane-oidc-secret-key
EOF
cat << 'EOF' > /opt/headscale-stack/caddy/Caddyfile
{
    default_sni 192.168.100.77
    auto_https disable_redirects
}

https://192.168.100.77 {
    tls internal
    log {
        output stdout
        format console
    }
    handle /admin* {
        reverse_proxy headplane:3000
    }
    handle {
        reverse_proxy headscale:8085
    }
}

http://:80 {
    handle /admin* {
        reverse_proxy headplane:3000
    }
    handle {
        reverse_proxy headscale:8085
    }
}

http://:8080 {
    reverse_proxy headscale:8085
}
EOF
cat << 'EOF' > /opt/headscale-stack/compose.yaml
services:
  dex:
    image: ghcr.io/dexidp/dex:v2.41.1
    container_name: dex
    restart: unless-stopped
    command: ["dex", "serve", "/etc/dex/config.yaml"]
    ports:
      - "5556:5556"
    volumes:
      - ./dex/config.yaml:/etc/dex/config.yaml:ro

  headscale:
    image: headscale/headscale:v0.28.0
    container_name: headscale
    restart: unless-stopped
    command: serve
    volumes:
      - /opt/headscale-stack/headscale/config:/etc/headscale
      - /opt/headscale-stack/headscale/data:/var/lib/headscale
    labels:
      me.tale.headplane.target: headscale

  caddy:
    image: caddy:2-alpine
    container_name: caddy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro
      - ./caddy/data:/data
    depends_on:
      - headscale

  headplane:
    image: ghcr.io/tale/headplane:0.7.0-beta.2
    container_name: headplane
    restart: unless-stopped
    ports:
      - "3000:3000"
    volumes:
      - /opt/headscale-stack/headplane/config.yaml:/etc/headplane/config.yaml:ro
      - /opt/headscale-stack/headplane/data:/var/lib/headplane
      - /opt/headscale-stack/headscale/config/config.yaml:/etc/headscale/config.yaml
      - /opt/headscale-stack/headscale/config/dns_records.json:/etc/headscale/dns_records.json
      - /opt/headscale-stack/headscale/config/acl.hujson:/etc/headscale/acl.hujson
      - /var/run/docker.sock:/var/run/docker.sock:ro
    depends_on:
      - headscale
      - dex
      - caddy
EOF
sudo docker compose -f /opt/headscale-stack/compose.yaml up -d headscale dex caddy

(**Note:** If you are connecting Headplane to Authentik, Keycloak, or Pocket ID instead of Dex, register `https://<your-domain-or-ip>/admin/oidc/callback` as the Redirect URI in your provider.)

## Create the Headscale User, Generate the API Key, and Start Headplane

Headplane links your OIDC login to a Headscale user. For this, it first checks the OIDC `sub` claim, and if that is not found, it attempts to find a match by comparing your email address against Headscale's list of users.

This block creates the admin user in Headscale with the matching `admin@example.com` email, captures a fresh 365-day API key into `$API_KEY`, writes `/opt/headscale-stack/headplane/config.yaml`, and starts Headplane.

sudo docker exec headscale headscale users create admin --display-name "Admin" --email "admin@example.com"
API_KEY=$(sudo docker exec headscale headscale apikeys create --expiration 365d | tail -n 1 | tr -d '\r')
cat << EOF > /opt/headscale-stack/headplane/config.yaml
server:
  host: "0.0.0.0"
  port: 3000
  base_url: "https://192.168.100.77"
  cookie_secret: "a8f5f167f44f4964e6c998dee827110c"
  cookie_secure: true
  data_path: "/var/lib/headplane"

headscale:
  url: "http://headscale:8085"
  public_url: "https://192.168.100.77"
  api_key: "$API_KEY"
  config_path: "/etc/headscale/config.yaml"
  config_strict: true
  dns_records_path: "/etc/headscale/dns_records.json"

oidc:
  issuer: "http://192.168.100.77:5556/dex"
  client_id: "headplane-oidc"
  client_secret: "headplane-oidc-secret-key"
  disable_api_key_login: false
  use_pkce: true

integration:
  docker:
    enabled: true
    container_label: "me.tale.headplane.target=headscale"
    socket: "unix:///var/run/docker.sock"
  agent:
    enabled: true
    host_name: "headplane-agent"
    cache_ttl: 180000
    work_dir: "/var/lib/headplane/agent"
EOF
sudo docker compose -f /opt/headscale-stack/compose.yaml up -d && sleep 6 && sudo docker logs headplane --tail 20

You do not need to manually create a pre-auth key for `headplane-agent` anymore. Headplane uses your `headscale.api_key` to generate a tag-only pre-auth key automatically on first boot and saves its `tailscaled.state` under `/var/lib/headplane/agent`.

![see output like this image.](https://trendboxgeek.com/content/images/2026/10/generated-image-a72bceb1-8c2d-4e83-91e5-74a711f262c1.png)

## Join a Target Server With `--ssh` Enabled

Any Linux machine you want to access via Browser SSH needs Tailscale installed and started with the `--ssh` flag. To test right on the same server, install Tailscale, register it against the local `:8080` listener, and restart `headplane` once so the agent immediately syncs both nodes:

curl -fsSL https://tailscale.com/install.sh | sh && KEY=$(sudo docker exec headscale headscale preauthkeys create --user 1 --reusable --expiration 24h | tail -n 1 | tr -d '\r') && sudo tailscale up --login-server=http://192.168.100.77:8080 --authkey="$KEY" --ssh && sudo docker restart headplane && sleep 6 && sudo docker exec headscale headscale nodes list

Both `headplane-agent` (`100.64.0.1`) and your server (`100.64.0.2`) will show up online:

```text
ID | Hostname        | Name            | MachineKey | NodeKey | User           | Tags                | IP addresses                  | Ephemeral | Connected
1  | headplane-agent | headplane-agent | [TJyo/]    | [cYz0m] | tagged-devices | tag:headplane-agent | 100.64.0.1, fd7a:115c:a1e0::1 | false     | online
2  | boxgeek         | boxgeek         | [pS74C]    | [uKuvZ] | admin          |                     | 100.64.0.2, fd7a:115c:a1e0::2 | false     | online

```

## Log In via SSO and Open Browser SSH

Open `https://192.168.100.77/admin ` in Brave or Firefox (or Chrome with hardware acceleration enabled). Make sure you include `/admin` in the URL, because visiting `/` directly hits Headscale and returns 404 Not Found. The home page opens as shown in the image below.

![Welcome page of Headplane.](https://trendboxgeek.com/content/images/2026/10/Screenshot-From-2026-10-27-13-09-55.png)

Click **Single Sign-On** at the bottom of the login card and sign in with `admin@example.com` and `password`.

![Log in page of Headplane.](https://trendboxgeek.com/content/images/2026/10/Screenshot-From-2026-10-27-13-10-26.png)

Because the email matches the `admin` user we created in Headscale, Headplane links your account automatically and gives the first OIDC user the **Owner** role.

Then, on the **Machines** page, your server row displays a green **`Tailscale SSH`** badge on the left and an **`SSH`** button on the right.

![connected to SSH.](https://trendboxgeek.com/content/images/2026/10/Screenshot-From-2026-10-26-19-22-08.png)

Click **SSH**, type your Linux username (for example, `trend`), and click **Connect**.

A popup window opens at `/admin/ssh/boxgeek?user=trend`, registers a temporary node (`ssh-xxxxxxxx-trend`), connects over WebSockets, and opens your `trend@boxgeek:~$` terminal. Once you close the window, Headplane's agent removes that temporary node on its next sync.

![pop up window.](https://trendboxgeek.com/content/images/2026/10/Screenshot-From-2026-10-27-13-12-16.png)

## Moving This Setup to Production

Once Headplane is connected to your OIDC provider and the agent is running, you rarely need to touch the Headscale CLI again. You can give viewer or admin access to other users, edit ACLs and DNS records from the web UI, and open a terminal on any Linux server straight from your browser.

If you plan to expose this stack outside your local network, swap Caddy's `tls internal` line for a real domain name so Let's Encrypt handles your certificates automatically, and remove the direct `3000` and `5556` port mappings from `compose.yaml` so all traffic goes through port `443`. From there, every new server you join with `sudo tailscale up --ssh` will show up in the dashboard ready for browser SSH within a couple of minutes.