- README.md: update secrets architecture to nixos/secrets.yaml and add Declarative NixOS Appliance section - docs/setup_guide.md: update SOPS secrets workflow and module paths to nixos/ - SECURITY.md: update host-level security recommendations for NixOS
8.8 KiB
🌐 Traefik Homelab Core
Welcome to the Traefik Homelab Core Control Plane — the central orchestrator, security perimeter, and edge gateway for the roadtotech.me homelab cluster.
This repository implements a Hardened Hub architecture where routing, SSL termination, identity management, container isolation, and orchestration are managed centrally, while user applications live in independent repositories in ~/Sites.
🏗️ Architectural Overview & Component Roles
The infrastructure is strictly divided into two operational tiers:
Internet (roadtotech.me)
│
▼
┌───────────────────────────────┐
│ Traefik Edge Proxy (:443) │
│ (Wildcard Let's Encrypt TLS) │
└───────┬───────────────┬───────┘
│ │
Public Traffic │ │ Auth Guarded
▼ ▼
[ Landing / Public ] [ Authelia SSO / 2FA ]
│ │
│ ▼
└───────► [ Data Plane Apps ]
(Sites: jellyfin, docs, etc.)
1. Control Plane Components (~/Core)
Traefik(v3.6): The edge reverse proxy and SSL terminator. Automatically obtains and maintains Let's Encrypt wildcard certificates (*.roadtotech.me,roadtotech.me) using the Dynu DNS-01 challenge. Routes incoming HTTP/HTTPS traffic to internal Docker containers overproxy-net.socket-proxy(tecnativa): Security barrier. Prevents Traefik and other containers from having direct access to/var/run/docker.sock, restricting access exclusively to safe container read operations via TCP (socket-net).Authelia: Single Sign-On (SSO) and Multi-Factor Authentication (2FA) identity gateway. Provides ForwardAuth middleware (authelia-auth@docker) that gates administrative dashboards and sensitive applications before traffic touches them.Portainer CE: Visual GUI for container inspection, stack lifecycle management, and log tracking.Dozzle: Lightweight real-time log viewer for all running containers, protected by Authelia SSO.Watchtower&Diun: Background daemons responsible for container image update notifications and automated updates.
2. Data Plane Applications (~/Sites)
User and service applications (e.g. dashboard, docs, jellyfin, excalidraw, gitea, mermaid, minecraft, ollama, pgsql, mongodb) live in isolated, dedicated git repositories under ~/Sites. They integrate with the Core control plane dynamically via the proxy-net Docker network and Traefik container labels.
🔒 Security Model & Secrets Architecture
The security model is built on zero hardcoded secrets and defense-in-depth:
[nixos/secrets.yaml] (Encrypted with SOPS + age keys)
│
▼ (Decrypted at boot by sops-nix using host SSH key)
[/run/secrets/rendered/homeserver.env] & [/run/secrets/rendered/traefik-deployments.env]
│
▼ (Fed via --env-file and appctl)
[Core & Sites Containers]
- SOPS & sops-nix Integration: All sensitive tokens (Dynu API key, Authelia session secrets, JWT keys, database passwords) are encrypted in
nixos/secrets.yamland decrypted by NixOS at runtime into in-memory/run/secrets/and/run/secrets/rendered/. - Edge TLS & HSTS: All external traffic is forced over HTTPS using Let's Encrypt wildcard certificates with strict redirect schemes (
https-redirect@docker). - Authelia ForwardAuth: Applications that require authentication declare
traefik.http.routers.<name>.middlewares=authelia-auth@docker, delegating identity verification to Authelia. - Socket Isolation: Direct Docker daemon sockets are completely hidden behind
socket-proxy.
🚀 Orchestration with appctl
Applications in ~/Sites are managed using the custom appctl CLI tool located in scripts/appctl.
Key Commands:
# List all application stacks with runtime container health and Git sync status
appctl list
# Fetch upstream git changes across all repositories before rendering status
appctl list --fetch
# List all applications AND core control plane services
appctl list --core
# Display comprehensive metadata, routing, environment, and Git diagnostics
appctl info docs
appctl info jellyfin
# Start, stop, or restart an application stack
appctl up docs
appctl down jellyfin
appctl restart dash
# Full atomic stack upgrade (clean check -> git pull --ff-only -> docker compose pull -> docker compose up -d -> appctl sync)
appctl update docs
appctl update core
appctl update all
# Validate resolved docker compose configuration
appctl config docs
# Synchronize Homepage dashboard services.yaml from app.yaml manifests
appctl sync
📦 Adding a New Application Stack
Adding a new application to the homelab is completely decentralized:
1. Create the App Directory
mkdir -p ~/Sites/homelab-myapp
cd ~/Sites/homelab-myapp
git init
2. Create app.yaml Manifest
Define the application metadata:
name: "myapp"
aliases:
- "app"
domain: "myapp.roadtotech.me"
description: "My Awesome New Homelab App"
visible: true
auth: false
networks:
- proxy-net
env:
CUSTOM_VAR: "value"
homepage:
title: "My App"
group: "Knowledge & Notes"
icon: "custom.png"
container: "myapp"
weight: 50
3. Create docker-compose.yml
services:
myapp:
image: myapp/image:latest
container_name: ${CONTAINER_NAME:-myapp}
restart: unless-stopped
networks:
- proxy-net
labels:
- "traefik.enable=true"
# HTTPS Router
- "traefik.http.routers.${CONTAINER_NAME:-myapp}.rule=Host(`${SERVICE_DOMAIN}`)"
- "traefik.http.routers.${CONTAINER_NAME:-myapp}.entrypoints=websecure"
- "traefik.http.routers.${CONTAINER_NAME:-myapp}.tls=true"
- "traefik.http.routers.${CONTAINER_NAME:-myapp}.service=${CONTAINER_NAME:-myapp}-svc"
# HTTP to HTTPS Redirect
- "traefik.http.routers.${CONTAINER_NAME:-myapp}-red.rule=Host(`${SERVICE_DOMAIN}`)"
- "traefik.http.routers.${CONTAINER_NAME:-myapp}-red.entrypoints=web"
- "traefik.http.routers.${CONTAINER_NAME:-myapp}-red.middlewares=https-redirect@docker"
# Service Target Port
- "traefik.http.services.${CONTAINER_NAME:-myapp}-svc.loadbalancer.server.port=8080"
networks:
proxy-net:
name: ${PROXY_NETWORK:-proxy-net}
external: true
4. Deploy and Sync
appctl up myapp
appctl will start the container, inject standard environment variables, and automatically recompile homelab-dashboard/config/services.yaml.
❄️ Declarative NixOS Appliance
This repository is a self-contained NixOS appliance. It defines the operating system, Docker infrastructure, firewall rules, automated DDNS updates, and host shell environment in a single flake.
Repository NixOS Layout:
flake.nix— Flake entrypoint definingnixosConfigurations.server.nixos/configuration.nix— Standalone headless host configuration (locale, SSH, Docker, packages).nixos/hardware-configuration.nix— Server hardware, disk mounts, and kernel parameters.nixos/secrets.yaml— SOPS-encrypted secrets for the server.nixos/modules/homeserver.nix—homeserver-core.service,homelab-gitops.service, and Authelia secrets.nixos/modules/traefik-deployments.nix— Traefik applications environment secrets (traefik-deployments.env).nixos/modules/dynu.nix— Dynu DDNS smart IP monitor timer and ddclient credentials.nixos/modules/shell.nix— Server-tailored bash shell profile, aliases, and utilities.
Common Operations:
# Rebuild and switch the running system
sudo nixos-rebuild switch --flake ~/Core#server
# (or use the built-in alias: nix-switch)
# Inspect core service units
systemctl status homeserver-core
journalctl -u homeserver-core -f
# Inspect GitOps webhook dispatcher
systemctl status homelab-gitops
# Inspect dynamic IP monitor
systemctl status dynu-monitor
Disaster Recovery:
Any clean machine can be provisioned into this server:
nixos-install --flake ~/Core#server
📄 License
This repository is released into the public domain under the Unlicense.