BLUEPRINT_ID // WG-001STARTER_EXAMPLE // SOVEREIGN_ARCH
The Escape Route: Sovereign Private Chat
A starter example for deploying your own end-to-end encrypted Matrix homeserver (Tuwunel) backed by Keycloak on self-hosted hardware. Use this baseline to customize your own domain, TLS routing, and identity settings.
Target OS Headless Linux
Identity / SSO Keycloak (2FA)
Protocol Matrix (Rust)
Runtime Docker Compose
docker-compose.yml (Starter Example)
# Starter example — replace placeholder passwords, set your domain, and wire up OIDC + TLS before production
services:
postgres:
image: postgres:15-alpine
container_name: keycloak_db
restart: unless-stopped
environment:
POSTGRES_DB: keycloak
POSTGRES_USER: keycloak
POSTGRES_PASSWORD: change_me_db_password
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- private_chat_net
keycloak:
image: quay.io/keycloak/keycloak:26.0
container_name: keycloak_auth
restart: unless-stopped
environment:
KC_DB: postgres
KC_DB_URL: jdbc:postgresql://postgres/keycloak
KC_DB_USERNAME: keycloak
KC_DB_PASSWORD: change_me_db_password
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: change_me_admin_password
# Switch to 'start' behind a TLS reverse proxy in production
command: start-dev
ports:
- "127.0.0.1:8080:8080"
depends_on:
- postgres
networks:
- private_chat_net
tuwunel:
image: ghcr.io/matrix-construct/tuwunel:latest
container_name: matrix_homeserver
restart: unless-stopped
environment:
TUWUNEL_SERVER_NAME: chat.yourdomain.com
TUWUNEL_DATABASE_PATH: /var/lib/tuwunel
TUWUNEL_PORT: 6167
TUWUNEL_ADDRESS: 0.0.0.0
TUWUNEL_ALLOW_REGISTRATION: "false"
TUWUNEL_ALLOW_FEDERATION: "false"
# Add your OIDC / Keycloak client settings here or mount a tuwunel.toml
volumes:
- tuwunel_data:/var/lib/tuwunel
ports:
- "127.0.0.1:6167:6167"
depends_on:
- keycloak
networks:
- private_chat_net
networks:
private_chat_net:
driver: bridge
volumes:
postgres_data:
tuwunel_data:Starter Checklist
- Deploy headless Linux with full-disk encryption (LUKS) and key-based SSH logins. Disable password authentication inside your
sshd_config. - Install Docker Engine and the Docker Compose plugin.
- Use the starter example above as your base
docker-compose.yml—replace all placeholder passwords, set your real domain, and add your OIDC config. - Launch the stack with
docker compose up -d. - Put a TLS reverse proxy (such as Caddy) in front if ports 80/443 are open, or connect your domain via an encrypted outbound tunnel if your ISP blocks those ports.
- Log into Keycloak to enforce Two-Factor Authentication and configure your Matrix client redirect URI before switching Keycloak to production mode.
Disclaimer: This starter example is provided strictly “as-is” for educational and research purposes. Review security, firewall, and TLS settings before exposing any self-hosted service online.