- Dockerfile 76.1%
- Shell 23.9%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| config | ||
| headplane | ||
| nginx | ||
| scripts | ||
| .env.example | ||
| .gitattributes | ||
| .gitignore | ||
| compose.integration.yml | ||
| docker-compose.yml | ||
| ENV.md | ||
| README.md | ||
Headplane
Self-hosted Headscale coordination server and Headplane administration UI, packaged for Docker Compose. The stack uses the official stable images, a project bridge, and persistent named volumes. No custom build, shared PostgreSQL, Redis, or new reverse proxy is needed. Headscale recommends SQLite for new deployments; Headplane also persists its own SQLite data.
Before You Start
- Use Docker Compose v2 on the same daemon for both services. Check
docker infoanddocker compose version(or use yourdocker-isolatedwrapper consistently). - The default host ports are 13000 (Headplane), 18080 (Headscale) and 19090 (metrics), all loopback-only. Adjust
.envif occupied. - For real remote nodes, arrange DNS and HTTPS on an independently reachable server or your existing
shared-nginxreverse proxy. The control server cannot depend on the new tailnet to be reachable by clients that have not joined it yet. - Existing Tailscale-hosted tailnets are separate from Headscale. This deployment creates a new control plane; it does not import old users, node keys, or machines. Re-enroll nodes unless restoring a compatible backup.
Setup
Extract the project to /opt/headplane, then:
cd /opt/headplane
bash scripts/setup.sh
vi .env
docker compose config --quiet
docker compose up -d
docker compose ps
setup.sh creates a 32-character random cookie secret without overwriting an existing secret. It also creates .env and each service’s config.yaml plus config/headscale/acl.json from their corresponding examples if absent. Existing files are never overwritten. The initial .env is already included for convenience. Keep the secret and .env private. The image reads the secret through a Compose secret mount. See ENV.md.
Commit config/headplane/config.yaml.example, config/headscale/config.yaml.example and config/headscale/acl.json.example, not the runtime config.yaml or acl.json files (all are Git-ignored). If the runtime files are already tracked, run git rm --cached -- config/headplane/config.yaml config/headscale/config.yaml to untrack them without deleting the local copies. Do not copy live secrets into the examples. On an existing deployment, merge the configuration fix into your local files rather than replacing customized settings.
Initialize the web UI
-
After both containers are healthy, generate an administrative API key:
docker compose exec headscale headscale apikeys create -
Open
http://127.0.0.1:13000/admin/(or the configured HTTPS URL with/admin/). Sign in with the generated API key. Treat it as an administrator password; do not commit or share it. Renew it before its expiration. -
Create a Headscale user in the UI, or use
docker compose exec headscale headscale users create myuser. -
Create a pre-auth key in the UI or use
docker compose exec headscale headscale preauthkeys create --user <USER_ID>(get ID usingheadscale users list). On a client usetailscale up --login-server=https://YOUR-CONTROL-HOST --auth-key=YOUR-PREAUTH-KEY. Follow the client-specific sign-in procedure; switching control servers changes tailnets. Do not do this over your only remote management connection.
Optional full Docker integration
Base mode allows API-based management (nodes, users, keys and database-backed ACLs). The Headscale config mount is read-only. To edit network/DNS configuration from Headplane and allow it to signal Headscale, use the optional overlay. This exposes the Docker daemon to Headplane, which is effectively privileged access even with a :ro socket mount. Keep the admin interface private; prefer a restricted socket proxy if you have one. On the isolated daemon set HEADPLANE_DOCKER_SOCKET=/run/docker-isolated/docker.sock in .env after checking the socket path. The host socket must be for the daemon actually running the stack.
stat -c '%n %a %u:%g' /run/docker-isolated/docker.sock
docker compose -f docker-compose.yml -f compose.integration.yml config --quiet
docker compose -f docker-compose.yml -f compose.integration.yml up -d
Use both -f flags for subsequent lifecycle commands in this mode. To return to base mode, run docker compose up -d without the overlay. The overlay replaces the shared Headscale configuration directory mount in Headplane with a writable one; Headscale retains its read-only view of the same directory. DNS files stay on the host, so review Git changes before committing. Do not overwrite edited DNS/config files on redeployment. No agent or OIDC is configured initially; these are optional for extra node telemetry and browser SSH.
HTTPS and remote access
Copy the example virtual hosts from nginx/ into your existing reverse proxy. Separate-domain HTTP bootstrap examples are provided in nginx/sites-available/; use Certbot with the Nginx plugin to install HTTPS as described in the Nginx README.
Set HEADSCALE_SERVER_URL and HEADPLANE_HEADSCALE__PUBLIC_URL to the same reachable HTTPS control URL, e.g. https://vpn.example.com. Set HEADPLANE_SERVER__BASE_URL to the actual admin origin (no /admin), and HEADPLANE_SERVER__COOKIE_SECURE=true. The Headscale proxy must support HTTP upgrade (including the Tailscale control protocol); ordinary HTTP forwarding alone is insufficient. For a local host proxy, use 127.0.0.1:13000 and 127.0.0.1:18080; for an existing container proxy, arrange access to this project's bridge or publish on an appropriate reachable host IP and firewall it. Do not publish metrics externally. Keep HEADPLANE_HEADSCALE__URL=http://headscale:8080 for internal API communication. No proxy or certificate config is installed automatically. See Headscale reverse proxy docs and Headplane Docker docs.
MagicDNS defaults to tailnet.home.arpa, distinct from the control host; change it in config/headscale/config.yaml if needed. Local DNS overrides are off. Embedded DERP is off; the default public DERP map is used. Review policy before adding untrusted users: the initial Headscale default may allow all nodes to communicate.
Access control (ACLs)
Both Headscale and Headplane mount config/headscale/ at /etc/headscale. The included acl.json and acl.json.example contain an explicit allow-all policy, matching a new deployment with no custom policy. Database mode remains the default in both YAML files; Headscale ignores the file in this mode, and Headplane can manage the database policy through its API.
Switch to file mode
-
If you already have a custom database policy, export it before switching:
docker compose exec -T headscale headscale policy get > /tmp/headscale-policy.json. Review the output before copying it overconfig/headscale/acl.json. The starter file does not import existing database rules. -
Run
bash scripts/setup.shif the ACL file is missing. Editconfig/headscale/acl.jsonto define your rules. The starter allows all nodes to connect to all ports; restrict this before enrolling untrusted devices. -
Edit
config/headscale/config.yamlwithviand set the existing policy block to:policy: mode: file path: /etc/headscale/acl.json -
Validate and restart Headscale to apply the mode change:
docker compose exec headscale headscale policy check --file /etc/headscale/acl.json docker compose restart headscale docker compose logs --tail=50 headscale
Headplane can still manage nodes, users and keys, but its policy editor is read-only in file mode. No additional file mount or image rebuild is required.
Update file-based rules
vi config/headscale/acl.json
docker compose exec headscale headscale policy check --file /etc/headscale/acl.json
docker compose kill -s HUP headscale
docker compose logs --tail=50 headscale
The directory mount makes edits visible even when the editor replaces the file. To return to database mode, change policy.mode to database and restart Headscale. The previous database policy is not synchronized with file mode; review it when switching back.
See Headscale policy documentation.
Validation and operation
docker compose run --rm --no-deps headscale configtest
docker compose ps
docker compose logs --tail=100 headscale headplane
curl -fsS http://127.0.0.1:18080/health
curl -fsSL http://127.0.0.1:13000/admin/ >/dev/null
docker stats --no-stream headplane headscale
Use the selected overlay flags when applicable. The upstream images are distroless, so shell-based healthchecks or exec sh are not appropriate. The project uses the provided native healthcheck commands. Review logs, test login, and enroll a test node before production use. Verify clean docker compose down and docker compose up -d; do not use down -v unless intentionally deleting state.
Backup and upgrade
Stop both services before making a consistent backup of the headplane_data and headscale_data named volumes, the config/ directory, .env, and secrets/. Back up the Headscale database and Noise private key together. Protect backups as credentials. Restore into the same version first, then follow upstream upgrade instructions; never downgrade a migrated database without restoring its matching backup. Edit versions in .env, pull images and recreate the services after reviewing release notes.
Standards and exceptions
Service keys and environment variables are alphabetized; resource limits, versions, published ports and log rotation are configurable. The stack uses native healthchecks, named volumes, read-only configuration by default, no-new-privileges, tmpfs, and init: true for Node. SQLite is intentional instead of shared PostgreSQL because Headscale discourages PostgreSQL for new deployments. The integration overlay is an explicit exception to read-only configuration and minimum daemon privilege. Advanced application-specific YAML settings are not all duplicated as active environment variables: doing so could override UI edits or enable optional features unintentionally. The pinned upstream configuration references in ENV.md cover the remaining options.
Static checks were performed when packaging; a live Docker lifecycle, actual container health, login, and node registration must still be verified on the target host.