docs: formalize hardened architecture and operational guides
- Added docs/architecture.md: Detailed the layered Hub model and security posture. - Added docs/usability.md: End-user guide for SSO, dashboard, and app management. - Added docs/troubleshooting.md: Common fixes for SSL, Auth, and Connectivity. - Updated docs/roadmap.md: Reflected completion of Phase 1 and adjusted priorities. - Updated README.md: Integrated documentation index and architectural overview.
This commit is contained in:
1 parent
2469ce31de
commit
52ede71f9b
6 files changed
+197
-93
No files matched your search
+2
-1
@@ -34,4 +34,5 @@ venv/
|
|||||||
# OS Metadata
|
# OS Metadata
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
apps/homepage/config/logs/homepage.log
|
apps/homepage/config/logs/
|
||||||
|
|
||||||
@@ -92,3 +92,16 @@ This policy is currently enabled on core infrastructure and is recommended for a
|
|||||||
- **SSO Integration:** Critical apps (Gitea, Dozzle, Portainer) are behind Authelia Forward Auth.
|
- **SSO Integration:** Critical apps (Gitea, Dozzle, Portainer) are behind Authelia Forward Auth.
|
||||||
- **Automatic TLS:** Traefik manages Let's Encrypt certificates via DNS-01 challenges with Dynu.
|
- **Automatic TLS:** Traefik manages Let's Encrypt certificates via DNS-01 challenges with Dynu.
|
||||||
- **Network Segmentation:** Services are isolated on `proxy-net` and `socket-net`.
|
- **Network Segmentation:** Services are isolated on `proxy-net` and `socket-net`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📚 Detailed Documentation
|
||||||
|
|
||||||
|
For more in-depth information, please refer to the following guides:
|
||||||
|
|
||||||
|
- **[Server Architecture](docs/architecture.md)**: Deep dive into the layered model, networking, and security posture.
|
||||||
|
- **[Usability & Operations](docs/usability.md)**: How to use the hub, add new apps, and manage updates.
|
||||||
|
- **[Troubleshooting](docs/troubleshooting.md)**: Solutions for common connectivity, SSL, and authentication issues.
|
||||||
|
- **[Project Roadmap](docs/roadmap.md)**: Current status and future planned features.
|
||||||
|
- **[Dynu IP Protocol](docs/dynu-ip-update-protocol.md)**: Technical details on the DDNS synchronization mechanism.
|
||||||
|
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# 🏗️ Server Architecture: Hardened Hub Model
|
||||||
|
|
||||||
|
The homeserver follows a **Layered Architecture** designed for security, observability, and modularity. It is split into two logical tiers: the **Control Plane** (Infrastructure) and the **Data Plane** (Applications).
|
||||||
|
|
||||||
|
## 1. Physical & Host Layer
|
||||||
|
- **OS**: Linux (Generic).
|
||||||
|
- **IP Sync**: A host-level systemd service (`scripts/dynu/`) monitors the public IP and updates Dynu DDNS records. This ensures that the external domain always points to the correct gateway.
|
||||||
|
- **Docker Engine**: Orchestrates all containerized services.
|
||||||
|
|
||||||
|
## 2. Infrastructure Layer (`infra/`)
|
||||||
|
The "Control Plane" manages the lifecycle and security of the entire stack.
|
||||||
|
|
||||||
|
### 🌐 Edge Gateway (`infra/core`)
|
||||||
|
- **Traefik v3**: Acts as the Reverse Proxy and SSL terminator.
|
||||||
|
- Handles **DNS-01 Challenges** via Dynu for wildcard SSL certificates.
|
||||||
|
- Routes traffic based on subdomains (e.g., `gitea.*`).
|
||||||
|
- **Socket-Proxy**: A secure bridge that protects the Docker socket. Services needing Docker access (Portainer, Watchtower) talk to this proxy instead of the raw socket, preventing container-escape vulnerabilities.
|
||||||
|
|
||||||
|
### 🔐 Identity & Access (`infra/authelia`)
|
||||||
|
- **Authelia**: Provides Single Sign-On (SSO) and Two-Factor Authentication (2FA).
|
||||||
|
- **Forward Auth**: Traefik delegates authentication to Authelia before allowing traffic to sensitive applications.
|
||||||
|
|
||||||
|
### 🛠️ Management & Maintenance
|
||||||
|
- **Portainer**: Graphical UI for managing Docker stacks and containers.
|
||||||
|
- **Watchtower**: Automatically pulls new images and restarts containers when updates are available.
|
||||||
|
- **Diun**: Notifies the administrator of new image tags.
|
||||||
|
|
||||||
|
## 3. Application Layer (`apps/`)
|
||||||
|
The "Data Plane" contains the services used by end-users. These are isolated on the `proxy-net` network and have no direct access to host resources unless explicitly defined.
|
||||||
|
|
||||||
|
- **Service Discovery**: 'Homepage' (the dashboard) provides a unified portal.
|
||||||
|
- **SSO Integration**: Apps like Gitea and Dozzle are integrated with Authelia for secure, authenticated access.
|
||||||
|
|
||||||
|
## 4. Networking Model
|
||||||
|
- **`proxy-net`**: Shared internal network for Traefik and all exposed applications.
|
||||||
|
- **`socket-net`**: Isolated network for communication between the Socket-Proxy and management tools.
|
||||||
|
- **External Exposure**: Only ports 80 and 443 are exposed to the internet. All other management (SSH, API) is restricted or handled via the reverse proxy.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🛡️ Security Posture
|
||||||
|
1. **No Root Docker**: Most containers are encouraged to run with specific PUID/PGID.
|
||||||
|
2. **Wildcard Certificates**: Wildcard SSL prevents domain enumeration by malicious scanners.
|
||||||
|
3. **Internal-Only Services**: Some tools (like Portainer) are reachable only via the local network or authenticated proxy.
|
||||||
|
4. **Log Rotation**: Global policy ensures container logs don't consume all disk space.
|
||||||
+34
-92
@@ -1,113 +1,55 @@
|
|||||||
# 🗺️ Project Roadmap: Arch-traefik-hub
|
# 🗺️ Project Roadmap: Hardened Private Cloud Hub
|
||||||
|
|
||||||
This roadmap reflects the current system maturity and next priorities.
|
This roadmap reflects the current system maturity and future priorities.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Phase 1: Core Gateway & DNS Stability 🔒 (Mostly Complete)
|
## ✅ Phase 1: Core Gateway & Infrastructure (Complete)
|
||||||
|
*Objective: Stable external access, identity management, and core security.*
|
||||||
|
|
||||||
Objective: stable external access with correct DNS resolution.
|
- [x] **Dynamic DNS:** Reliable IP synchronization via systemd-based Dynu updater.
|
||||||
|
- [x] **Edge Routing:** Traefik v3 with Let's Encrypt (DNS-01) automation.
|
||||||
- [x] NAT Port Forwarding (80/443)
|
- [x] **Layered Architecture:** Clear separation between `infra/` (control plane) and `apps/` (data plane).
|
||||||
- [x] Dynu DDNS IP synchronization (systemd-based)
|
- [x] **Identity & SSO:** Authelia integration with 2FA/OIDC support.
|
||||||
- [x] Traefik deployment with reverse proxy
|
- [x] **Security Hardening:** Docker socket proxy, internal network segmentation, and non-root users where possible.
|
||||||
- [ ] ACME DNS-01 validation (Let's Encrypt)
|
- [x] **Centralized Logging:** Real-time log streaming via Dozzle.
|
||||||
- [ ] End-to-end HTTPS verification across all services
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
- IP drift is now handled independently via Dynu updater
|
|
||||||
- Remaining risk is ACME challenge correctness
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Phase 2: Observability & Control Plane 📊
|
## 🏗️ Phase 2: Application Ecosystem & Observability (In Progress)
|
||||||
|
*Objective: Expand utility and improve "Single Pane of Glass" monitoring.*
|
||||||
|
|
||||||
Objective: reduce reliance on CLI and improve visibility.
|
- [x] **Service Discovery:** 'Homepage' dashboard integration.
|
||||||
|
- [x] **Visual Tools:** Excalidraw and Mermaid deployment.
|
||||||
- [ ] FastAPI backend for service metadata
|
- [x] **Development:** Self-hosted Gitea with SSO.
|
||||||
- [ ] Minimal JS frontend dashboard
|
- [x] **AI/ML:** Scalable Ollama cluster with model management.
|
||||||
- [ ] Integration with Docker socket (read-only)
|
- [ ] **Unified Health:** Integrate Traefik/Docker health checks into the Homepage dashboard.
|
||||||
- [ ] Deep-linking to Dozzle logs per service
|
- [ ] **Resource Monitoring:** Add lightweight metrics (e.g., Glances or Netdata) with dashboard widgets.
|
||||||
- [ ] Health/status indicators for:
|
|
||||||
- containers
|
|
||||||
- domains
|
|
||||||
- SSL certificates
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Phase 3: Service Ecosystem Expansion 🚀
|
## 🚀 Phase 3: Automation & Resilience
|
||||||
|
*Objective: Move from "manual maintenance" to "autonomous operations".*
|
||||||
|
|
||||||
Objective: increase utility without compromising isolation.
|
- [x] **Automated Updates:** Watchtower and Diun for image lifecycle management.
|
||||||
|
- [ ] **Backup Strategy:** Automated, encrypted off-site backups for persistent volumes (Gitea, DBs).
|
||||||
- [ ] Excalidraw + diagram tooling
|
- [ ] **Infrastructure as Code:** Further modularization of the `up.sh` script into a more robust CLI or Ansible-based setup.
|
||||||
- [ ] Expand Ollama cluster (load + memory tuning)
|
- [ ] **Alerting:** Push notifications (via Gotify/Ntfy) for system failures, auth breaches, or IP update issues.
|
||||||
- [ ] Add developer-focused tools (CI, registry, etc.)
|
|
||||||
- [ ] Define service templates for quick onboarding
|
|
||||||
|
|
||||||
Constraints:
|
|
||||||
- Must use `proxy-net`
|
|
||||||
- Must be Traefik-exposed
|
|
||||||
- Must remain resource-aware
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Phase 4: Network Optimization & Resilience 🌐
|
## 🌐 Phase 4: Network Optimization
|
||||||
|
*Objective: Reduce latency and external dependencies.*
|
||||||
|
|
||||||
Objective: reduce external dependencies and improve latency.
|
- [ ] **Local DNS:** Ad-blocking DNS (Pi-hole/AdGuard Home) for LAN clients.
|
||||||
|
- [ ] **Hairpin NAT:** Validation and optimization for internal traffic routing.
|
||||||
- [ ] Local DNS resolver (Pi-hole or equivalent)
|
- [ ] **VPN Integration:** WireGuard-based remote access for private management without public exposure.
|
||||||
- [ ] Internal hostname resolution (LAN-first)
|
|
||||||
- [ ] NAT hairpinning validation across devices
|
|
||||||
- [ ] Optional fallback DNS providers for redundancy
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Phase 5: Hardening & Reliability ⚙️
|
## 📜 Engineering Principles
|
||||||
|
|
||||||
Objective: move from “working” to “robust”.
|
1. **Idempotency:** All deployment scripts (`up.sh`, `down.sh`) must be safe to run repeatedly.
|
||||||
|
2. **Layered Security:** No single point of failure. If the gateway is breached, apps are still behind SSO.
|
||||||
- [ ] Add alerting (failed Dynu updates, SSL issues)
|
3. **Auditability:** Every change is reflected in documentation and Git history.
|
||||||
- [ ] Timer tuning based on real IP volatility
|
4. **Resilience:** Infrastructure must survive reboots and network outages automatically.
|
||||||
- [ ] Rate-limit awareness for Dynu API
|
|
||||||
- [ ] Backup strategy for:
|
|
||||||
- Traefik config
|
|
||||||
- ACME storage
|
|
||||||
- [ ] Evaluate IPv6 support (explicitly out-of-scope so far)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 💡 Engineering Notes
|
|
||||||
|
|
||||||
### Separation of Concerns
|
|
||||||
|
|
||||||
- Dynu updater:
|
|
||||||
- ensures correct **public IP**
|
|
||||||
- runs via systemd (host-level)
|
|
||||||
|
|
||||||
- Traefik:
|
|
||||||
- ensures **TLS + routing**
|
|
||||||
- runs in Docker
|
|
||||||
|
|
||||||
This separation prevents coupling failures (e.g., container restart affecting DNS correctness).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Failure Model
|
|
||||||
|
|
||||||
- **Degraded**
|
|
||||||
- DNS failure → HTTP fallback
|
|
||||||
- Provider-specific issues
|
|
||||||
|
|
||||||
- **Error**
|
|
||||||
- No valid IP found
|
|
||||||
- Dynu API failure
|
|
||||||
|
|
||||||
Only **successful external sync** mutates local state.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### How to Use This Roadmap
|
|
||||||
|
|
||||||
- Updated after stable merges into `main`
|
|
||||||
- Items should represent **deployable increments**, not ideas
|
|
||||||
- Avoid speculative features unless tied to concrete problems
|
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
# 🩺 Troubleshooting Guide
|
||||||
|
|
||||||
|
Common issues and their resolutions for the Hardened Hub.
|
||||||
|
|
||||||
|
## 🌐 Connectivity Issues
|
||||||
|
### 1. Site is unreachable (General)
|
||||||
|
- **Check External IP**: Verify if your public IP matches the DNS record at Dynu.
|
||||||
|
- Run `scripts/dynu/run-once.sh` to force an update.
|
||||||
|
- **Check Traefik Status**:
|
||||||
|
- `docker compose -f infra/core/docker-compose.yml ps`
|
||||||
|
- Ensure Traefik is running and port 80/443 are mapped.
|
||||||
|
|
||||||
|
### 2. "Bad Gateway" (502) or "Service Unavailable" (503)
|
||||||
|
- This usually means the application container is down or not connected to the `proxy-net`.
|
||||||
|
- **Action**: Verify the app container is running:
|
||||||
|
```bash
|
||||||
|
docker ps | grep <app_name>
|
||||||
|
```
|
||||||
|
- **Action**: Check container logs via Dozzle or `docker logs`.
|
||||||
|
|
||||||
|
## 🔒 SSL & Certificate Issues
|
||||||
|
### 1. "Your connection is not private"
|
||||||
|
- Traefik might be struggling with the Let's Encrypt challenge.
|
||||||
|
- **Action**: Check Traefik logs for "ACME" or "LE" errors:
|
||||||
|
```bash
|
||||||
|
docker compose -f infra/core/docker-compose.yml logs -f traefik
|
||||||
|
```
|
||||||
|
- **Common Cause**: Dynu API key is incorrect or API rate limits were hit.
|
||||||
|
|
||||||
|
### 2. Certificate is not valid for the subdomain
|
||||||
|
- Ensure the Traefik `Host` rule in your `docker-compose.yml` labels is correct.
|
||||||
|
|
||||||
|
## 🔐 Authentication (Authelia) Issues
|
||||||
|
### 1. Stuck in a Login Loop
|
||||||
|
- This often happens if the browser clock or server clock is out of sync.
|
||||||
|
- **Action**: Sync the server time (`sudo ntpdate pool.ntp.org`).
|
||||||
|
- **Action**: Clear browser cookies for your domain.
|
||||||
|
|
||||||
|
### 2. Forbidden (403) after login
|
||||||
|
- Your user may not have the required permissions in `infra/authelia/config/configuration.yml`.
|
||||||
|
- **Action**: Check the `access_control` section in the Authelia config.
|
||||||
|
|
||||||
|
## 🐳 Docker & Performance
|
||||||
|
### 1. Disk is full
|
||||||
|
- **Cause**: Usually excessive logs or orphaned volumes.
|
||||||
|
- **Action**: Run the cleanup command:
|
||||||
|
```bash
|
||||||
|
docker system prune -a --volumes
|
||||||
|
```
|
||||||
|
- **Action**: Check `apps/homepage/config/logs/` and other app-specific log paths.
|
||||||
|
|
||||||
|
### 2. High CPU/RAM Usage
|
||||||
|
- Check the Homepage dashboard or run `docker stats` to identify the culprit.
|
||||||
|
- **Common Culprit**: Ollama during model inference or Gitea indexing large repos.
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
# 🖱️ Usability & Operational Notes
|
||||||
|
|
||||||
|
This guide explains how to interact with the Hardened Hub once it is deployed.
|
||||||
|
|
||||||
|
## 🔑 Authentication (SSO)
|
||||||
|
Most services are protected by **Authelia**.
|
||||||
|
1. When you access a protected service (e.g., `gitea.*`), you will be redirected to the Auth Portal (`auth.*`).
|
||||||
|
2. Log in with your credentials.
|
||||||
|
3. Once authenticated, you will have access to all SSO-enabled services for the duration of your session.
|
||||||
|
|
||||||
|
## 🧭 Navigating the Hub
|
||||||
|
The **Homepage** dashboard is your central entry point:
|
||||||
|
- **URL**: `https://arch-services.mywire.org`
|
||||||
|
- **Widgets**: View the health of Docker containers, system resources, and quick links to all deployed applications.
|
||||||
|
|
||||||
|
## 🛠️ Service Management
|
||||||
|
### Deployment Commands
|
||||||
|
Use the provided scripts for lifecycle management:
|
||||||
|
- `./up.sh`: Starts everything.
|
||||||
|
- `./up.sh --infra-only`: Starts only the control plane (routing, auth, monitoring).
|
||||||
|
- `./down.sh`: Stops and removes all containers gracefully.
|
||||||
|
|
||||||
|
### Managing a Specific Service
|
||||||
|
To restart or view logs for a single service (e.g., Gitea):
|
||||||
|
```bash
|
||||||
|
cd apps/gitea
|
||||||
|
docker compose restart
|
||||||
|
docker compose logs -f
|
||||||
|
```
|
||||||
|
|
||||||
|
## ➕ Adding a New Application
|
||||||
|
To add a new service to the Hub:
|
||||||
|
1. Create a directory in `apps/your-app`.
|
||||||
|
2. Add a `docker-compose.yml`.
|
||||||
|
3. Ensure it connects to the `proxy-net` network:
|
||||||
|
```yaml
|
||||||
|
networks:
|
||||||
|
proxy-net:
|
||||||
|
external: true
|
||||||
|
```
|
||||||
|
4. Add Traefik labels for routing and (optional) Authelia labels for SSO.
|
||||||
|
5. Add the service to `apps/homepage/config/services.yaml` to see it on the dashboard.
|
||||||
|
|
||||||
|
## 📦 Container Updates
|
||||||
|
- **Automated**: Watchtower checks for updates every few hours.
|
||||||
|
- **Manual**: Use Portainer (`portainer.*`) to manually pull new images and recreate containers with a single click.
|
||||||
|
|
||||||
|
## 📝 Logging
|
||||||
|
Real-time logs can be viewed via **Dozzle** at `https://logs.arch-services.mywire.org`. This is preferred over `docker logs` for quick debugging across multiple containers.
|
||||||
Reference in new issue
Block a user