docs(homelab): add Stalwart mail server, LLDAP, and multirepo refactor documentation
Brain Structural Validation / Validate Markdown Structure & Links (push) Failing after 7s
Brain Structural Validation / Validate Markdown Structure & Links (push) Failing after 7s
Curate operational guides, architectural evaluations, and completed plans for the Stalwart mail server + Brevo relay deployment, LLDAP dynamic user directory integration, and Homepage multirepo reintegration into Core.
This commit is contained in:
1 parent
ed2d9b997c
commit
2f1d87c599
14 files changed
+1377
No files matched your search
@@ -77,6 +77,9 @@ Implementation roadmaps currently in progress (`status: active`) that are active
|
||||
Operational runbooks and procedures for daily administration:
|
||||
|
||||
* [**Onboarding a New Application Stack**](guides/onboarding-a-new-service.md) — Step-by-step procedure for deploying new Docker Compose services in `~/Sites` with `app.yaml` and Traefik routing.
|
||||
* [**LLDAP & Authelia SSO Integration Runbook**](guides/lldap-authelia-integration.md) — Dynamic user directory configuration, Authelia LDAP auth, and pre-commit quality gate checks.
|
||||
* [**Mail Deliverability & Outbound Relay Guide**](guides/mail-deliverability-rdns-relay-guide.md) — Solving residential IP/PTR blocks and Spamhaus PBL using Stalwart and Brevo SMTP relay.
|
||||
* [**Homepage Dashboard Reintegration into Core**](guides/homepage-core-reintegration.md) — Clean service discovery and configuration of gethomepage in Homelab Core.
|
||||
* [**Managing Secrets and Authelia Users**](guides/managing-secrets-and-authelia-users.md) — Guide for editing SOPS-encrypted secrets and managing user authentication credentials.
|
||||
* [**Server Maintenance and System Updates Runbook**](guides/server-maintenance-and-updates.md) — Standard operating procedure for NixOS updates, garbage collection, and container pruning.
|
||||
* [**Appctl & Application Manifests (`app.yaml`) User Guide**](guides/appctl-operations-and-manifest-guide.md) — Comprehensive reference for the `appctl` CLI tool and `app.yaml` schema.
|
||||
@@ -91,6 +94,13 @@ Operational runbooks and procedures for daily administration:
|
||||
Archived and foundational documentation for completed milestones:
|
||||
|
||||
### Resolved Architectural Discussions
|
||||
* [**Stalwart Mail Server Evaluation for Homelab Core**](discussions/mail-server-evaluation-stalwart.md) — Evaluated Stalwart vs Mailcow, Poste.io, and Postfix; resolved via Stalwart deployment.
|
||||
* [**Hostinger Business Email vs. Self-Hosted Stalwart**](discussions/hostinger-vs-stalwart-email-evaluation.md) — Compared cloud SaaS mail vs self-hosted mail with smart host relay.
|
||||
* [**Dual-Email Schema: Internal Mailboxes vs External Recovery**](discussions/dual-email-schema-lldap-stalwart.md) — Solved password recovery loops in identity directories with separate `mail` and `recovery_email` attributes.
|
||||
* [**Decoupling User Management from Secrets via LLDAP**](discussions/authelia-dynamic-user-backend-lldap.md) — Migrated from static SOPS user databases to dynamic LDAP authentication.
|
||||
* [**Authelia Session Lifetimes & Email Architecture**](discussions/authelia-session-email-architecture.md) — Configured 7d/3d session policies and email-based perimeter security.
|
||||
* [**Homelab Repository Location & Placement Analysis**](discussions/homelab-repo-location-analysis.md) — Evaluated `~/Homelab` vs `~/Projects/homelab`; resolved via dedicated `~/Homelab` tree.
|
||||
* [**Multirepo Refactor: Homepage & Learning Hub Separation**](discussions/multirepo-refactor-homepage-courses.md) — Decoupled dashboard infrastructure from domain applications.
|
||||
* [**NixOS Monorepo vs. Multi-Repo Architecture**](discussions/nixos-monorepo-vs-multirepo.md) — Evaluated workstation and server decoupling; resolved via appliance migration.
|
||||
* [**Decoupling `nixos-config` and `homelab-core`**](discussions/nixos-monorepo-decoupling.md) — Migration inventory and separation plan; resolved via repository split.
|
||||
* [**Dynamic Decentralized GitOps Dispatcher Architecture**](discussions/gitops-dispatcher-architecture.md) — Decoupled deployment webhook design; implemented in production.
|
||||
@@ -98,6 +108,8 @@ Archived and foundational documentation for completed milestones:
|
||||
* [**Dynu DDNS Polling Frequency and Rust Migration**](discussions/dynu-monitor-polling-and-language-tradeoffs.md) — Investigated polling intervals and language trade-offs; resolved via `dynu-monitor-rust-daemon.md` plan.
|
||||
|
||||
### Completed Plans
|
||||
* 🟢 [**Stalwart Mail Server & SnappyMail Webmail Deployment**](plans/stalwart-email-server-implementation-plan.md)
|
||||
* 🟢 [**Multirepo Refactor of Homepage & Learning Hub**](plans/multirepo-refactor-homepage-courses.md)
|
||||
* 🟢 [**Architecture Consolidation & Hardening Roadmap v1**](archive/architecture-consolidation-roadmap.md) (Superseded by v2)
|
||||
* 🟢 [**Turn `homelab-core` into a Declarative NixOS Appliance**](archive/nixos-appliance-migration.md)
|
||||
* 🟢 [**Core & Sites Cutover and Testing Plan**](archive/core-sites-cutover-testing-plan.md)
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
---
|
||||
type: discussion
|
||||
project: homelab
|
||||
date: 2026-09-14
|
||||
tags:
|
||||
- homelab
|
||||
- authelia
|
||||
- lldap
|
||||
- auth
|
||||
---
|
||||
|
||||
# Decoupling User Management from Secrets: Authelia + LLDAP Architecture
|
||||
|
||||
## Overview
|
||||
|
||||
Currently, Authelia uses a static `file` authentication backend (`/config/users.yml:ro`), decrypted and mounted from SOPS secrets via NixOS (`/run/secrets/rendered/users.yml`).
|
||||
|
||||
While this ensures that initial user definitions are encrypted in git, it introduces major operational friction:
|
||||
- **No CRUD Operations**: Adding, modifying, or deleting users requires manually editing SOPS secrets, running `nixos-rebuild`, and restarting Authelia.
|
||||
- **No Self-Service**: Users cannot change or reset passwords without administrator intervention in secrets files.
|
||||
- **Coupled Concerns**: User accounts (dynamic identity data) are conflated with infrastructure configuration (static secrets).
|
||||
|
||||
---
|
||||
|
||||
## The Solution: LDAP Authentication Backend via LLDAP
|
||||
|
||||
Authelia does not maintain its own internal user database with a CRUD API; by design, it delegates dynamic identity management to **LDAP** (Lightweight Directory Access Protocol).
|
||||
|
||||
The homelab and small-organization standard for this is **LLDAP** (*Lightweight LDAP*).
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
subgraph Browser ["Client Browser"]
|
||||
U["User / Admin"]
|
||||
end
|
||||
|
||||
subgraph TraefikProxy ["Traefik Reverse Proxy"]
|
||||
T["Traefik (TLS / Routing)"]
|
||||
end
|
||||
|
||||
subgraph IdentityPlane ["Identity & Access Control Plane"]
|
||||
A["Authelia (auth.roadtotech.me)"]
|
||||
L["LLDAP Web UI & Server (users.roadtotech.me)"]
|
||||
LDB[("LLDAP SQLite DB\n(/data/users.db)")]
|
||||
end
|
||||
|
||||
subgraph SitesPlane ["Sites & Protected Apps"]
|
||||
H["Houston"]
|
||||
J["Jellyfin"]
|
||||
G["Gitea"]
|
||||
end
|
||||
|
||||
U -->|"1. HTTPS Request"| T
|
||||
T -->|"2. Forward Auth Verify"| A
|
||||
A -->|"3. Query User / Verify Password (LDAP:3890)"| L
|
||||
L <-->|"Read/Write Credentials"| LDB
|
||||
|
||||
U -.->|"Admin / Self-Service CRUD (Web UI)"| L
|
||||
T -->|"4. Allowed Access"| SitesPlane
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Why LLDAP?
|
||||
|
||||
| Feature | Authelia `file` Backend (Current) | Authelia + LLDAP (Proposed) | OpenLDAP / FreeIPA |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| **User CRUD** | ❌ None (Manual YAML edit) | **Web UI & REST/GraphQL API** | CLI / phpLDAPadmin (Complex) |
|
||||
| **Secret Updates** | ❌ Required for every change | **Never touched after bootstrap** | Never touched after bootstrap |
|
||||
| **Memory Footprint** | ~30 MB | **~15–25 MB (Rust binary)** | 150 MB – 1.5 GB |
|
||||
| **Storage Backend** | Flat YAML | Single SQLite file (or PostgreSQL) | BDB / MDB flat files |
|
||||
| **Self-Service** | ❌ No | Users can change passwords / emails | Needs third-party portal |
|
||||
| **Group RBAC** | Static YAML list | Dynamic groups (Admins, Family, Devs) | Standard LDAP groups |
|
||||
| **External Integrations** | Authelia only | Direct LDAP for apps (Gitea, Jellyfin, Nextcloud) | Universal LDAP |
|
||||
|
||||
---
|
||||
|
||||
## How Secrets Are Completely Decoupled
|
||||
|
||||
Under the LLDAP architecture, **SOPS only manages infrastructure bootstrap secrets once**:
|
||||
|
||||
1. `LLDAP_JWT_SECRET`: Used by LLDAP to sign authentication tokens for its Web UI.
|
||||
2. `LLDAP_LDAP_USER_PASS`: A dedicated read-only bind account password used by Authelia to query the directory (`uid=authelia,ou=people,dc=roadtotech,dc=me`).
|
||||
|
||||
Once these two secrets are set, **you never touch SOPS or run `nixos-rebuild` again for identity operations**:
|
||||
- Adding a new family member, team member, or bot account is done via `https://users.roadtotech.me` (or via `curl` against LLDAP's REST API).
|
||||
- Passwords, 2FA registration, and group memberships are saved instantly to persistent storage (`./data/users.db`).
|
||||
- Authelia validates credentials dynamically against LLDAP in real time.
|
||||
|
||||
---
|
||||
|
||||
## Authelia Configuration Comparison
|
||||
|
||||
### Current (`file` backend)
|
||||
```yaml
|
||||
authentication_backend:
|
||||
file:
|
||||
path: /config/users.yml
|
||||
```
|
||||
|
||||
### Proposed (`ldap` backend with LLDAP)
|
||||
```yaml
|
||||
authentication_backend:
|
||||
ldap:
|
||||
implementation: lldap
|
||||
address: 'ldap://lldap:3890'
|
||||
timeout: 5s
|
||||
start_tls: false
|
||||
base_dn: 'dc=roadtotech,dc=me'
|
||||
additional_users_dn: 'ou=people'
|
||||
users_filter: '(&({username_attribute}={input})(objectClass=person))'
|
||||
additional_groups_dn: 'ou=groups'
|
||||
groups_filter: '(member={dn})'
|
||||
user: 'uid=authelia,ou=people,dc=roadtotech,dc=me'
|
||||
password: '{{ env "AUTHELIA_LDAP_BIND_PASSWORD" }}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Integration Plan into Core
|
||||
|
||||
1. **Add `lldap` Service to `Core/docker-compose.yml`**:
|
||||
- Image: `nitnelave/lldap:stable`
|
||||
- Network: `proxy-net` (for Traefik web UI) and `internal-net` or `socket-net` (for Authelia LDAP communication).
|
||||
- Domain: `users.roadtotech.me` (protected by Traefik + optional 2FA).
|
||||
- Storage: Persistent volume `./config/lldap/data:/data`.
|
||||
|
||||
2. **Bootstrap Secrets in SOPS**:
|
||||
- Generate `LLDAP_JWT_SECRET` and `AUTHELIA_LDAP_BIND_PASSWORD`.
|
||||
- Store them in `traefik-deployments.env` via sops-nix.
|
||||
|
||||
3. **Migrate Users**:
|
||||
- Create initial users in LLDAP with their respective groups (`admin`, `users`).
|
||||
|
||||
4. **Switch Authelia Backend**:
|
||||
- Switch `authentication_backend` from `file` to `ldap` in `Core/config/authelia/configuration.yml`.
|
||||
- Remove `/run/secrets/rendered/users.yml` volume mount from `authelia`.
|
||||
|
||||
5. **Register on Dashboard**:
|
||||
- Expose LLDAP as "Identity & User Directory" under Core Infrastructure on Homepage.
|
||||
@@ -0,0 +1,88 @@
|
||||
---
|
||||
type: discussion
|
||||
project: homelab
|
||||
date: 2026-09-14
|
||||
tags:
|
||||
- homelab
|
||||
- authelia
|
||||
- security
|
||||
- auth
|
||||
---
|
||||
|
||||
# Homelab Architecture: Authelia Session Lifetimes, Perimeter Security, and Self-Hosted Mail with LLDAP
|
||||
|
||||
## 1. Authelia Session & Expiration Dynamics
|
||||
|
||||
In Authelia, authentication sessions are managed via signed, encrypted session cookies and tokens.
|
||||
|
||||
### Configuration Overview
|
||||
```yaml
|
||||
session:
|
||||
name: authelia_session
|
||||
secret: '{{ env "AUTHELIA_SESSION_SECRET" }}'
|
||||
expiration: 43200 # 12 hours (overall lifetime)
|
||||
inactivity: 3600 # 1 hour (rolling idle timeout)
|
||||
remember_me: 1M # 1 month (if "Remember Me" is checked)
|
||||
```
|
||||
|
||||
- **Inactivity Timeout (`inactivity: 3600`)**: If the user leaves browser tabs open but does not generate HTTP requests through Traefik forward-auth for 1 hour, the session is invalidated for security.
|
||||
- **Hard Expiration (`expiration: 43200`)**: Without checking "Remember Me", the session expires after 12 hours regardless of activity.
|
||||
- **Remember Me (`remember_me: 1M`)**: When the user checks "Remember Me" at login, Authelia issues a persistent cookie valid for 1 month, bypassing the short inactivity timeout.
|
||||
|
||||
---
|
||||
|
||||
## 2. Dashboard & LLDAP Perimeter Security (Authelia Forward-Auth)
|
||||
|
||||
### Dashboard (`dashboard.roadtotech.me`)
|
||||
- **Risk**: Homepage exposes internal service names, backend IPs, container health metrics, and direct links to administrative portals.
|
||||
- **Protection**: Bound to Traefik router middleware `authelia-auth@docker`. Unauthenticated requests immediately receive `302 Found` redirecting to `https://auth.roadtotech.me`.
|
||||
|
||||
### LLDAP Admin UI (`users.roadtotech.me`)
|
||||
- **Protection**: Bound to `authelia-auth@docker` with `policy: one_factor`.
|
||||
- **Defense in Depth**: Even though LLDAP has its own internal login screen and optional TOTP 2FA, placing it behind Authelia prevents public internet scanners and automated bots from probing the LLDAP port directly.
|
||||
|
||||
---
|
||||
|
||||
## 3. Self-Hosted Email Server Architecture
|
||||
|
||||
### Should Mail be an "App" or part of "Core"?
|
||||
**Recommendation**: **Core Infrastructure**.
|
||||
|
||||
#### Rationale:
|
||||
1. **Foundational Service**: Mail is not just a user-facing app (like a webmail frontend); it is a core control plane dependency. Authelia (password resets), Diun (container updates), Gitea (collaboration), and Nextcloud all rely on SMTP to function.
|
||||
2. **Network Requirements**: An email server requires host port bindings that bypass Traefik:
|
||||
- Port 25 (SMTP incoming/relay)
|
||||
- Port 587 (Submission / STARTTLS)
|
||||
- Port 465 (SMTPS)
|
||||
- Port 993 (IMAPS)
|
||||
3. **Domain & DNS Invariants**: Email relies on root-domain DNS records: MX, SPF, DKIM (cryptographic keys in Core), and DMARC. Managing this inside Core ensures tight cohesion with Traefik TLS and DNS automation.
|
||||
|
||||
### Integrating Email with LLDAP Directory
|
||||
**Can LLDAP serve as the user database for a mail server? Yes, 100%.**
|
||||
|
||||
Modern self-hosted mail servers (such as **Stalwart Mail Server**, **Mailcow**, or **Dovecot + Postfix**) natively support LDAP:
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
subgraph Client ["Clients"]
|
||||
U["Webmail / Thunderbird / Mobile"]
|
||||
end
|
||||
|
||||
subgraph MailCore ["Mail Server (e.g. Stalwart Mail / Dovecot)"]
|
||||
M["SMTP / IMAP / JMAP Engine"]
|
||||
end
|
||||
|
||||
subgraph DirectoryPlane ["LLDAP Directory"]
|
||||
L["LLDAP (ldap://lldap:3890)"]
|
||||
LDB[("users.db")]
|
||||
end
|
||||
|
||||
U -->|"Authenticate (IMAP/SMTP)"| M
|
||||
M -->|"Verify user & password (LDAP)"| L
|
||||
L <--> LDB
|
||||
```
|
||||
|
||||
#### Key Advantages:
|
||||
1. **Single Source of Truth**: Creating `jane` in LLDAP (`users.roadtotech.me`) with `jane@roadtotech.me` instantly provisions her mailbox in the mail server.
|
||||
2. **Unified Passwords**: Users log into Authelia SSO, Gitea, Nextcloud, and their Email using the exact same password.
|
||||
3. **Automated Groups**: LLDAP groups (e.g., `team@roadtotech.me`) can map to mail distribution lists or aliases.
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
type: discussion
|
||||
project: homelab
|
||||
date: 2026-09-15
|
||||
tags:
|
||||
- homelab
|
||||
- email
|
||||
- lldap
|
||||
- stalwart
|
||||
- auth
|
||||
---
|
||||
|
||||
# Dual-Email Architecture: Internal Mailboxes (`@roadtotech.me`) vs. External Recovery (`@gmail.com`)
|
||||
|
||||
## The Problem: The "Locked Inbox" Chicken-and-Egg Catch-22
|
||||
|
||||
If a self-hosted mail server (Stalwart) is paired with an identity directory (LLDAP), setting `mail` exclusively to the internal domain (`kiskaadee@roadtotech.me`) creates a critical failure mode:
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
A["User forgets password"] --> B["Requests password reset in Authelia / LLDAP"]
|
||||
B --> C["Reset token sent to kiskaadee@roadtotech.me"]
|
||||
C --> D["User cannot log into kiskaadee@roadtotech.me\nbecause password is forgotten!"]
|
||||
D --> E["❌ Permanent account lockout without manual admin intervention"]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## The Solution: Dual-Email Schema
|
||||
|
||||
Every production identity directory (Google Workspace, Microsoft Entra ID, Okta) separates the **Primary Organizational Mailbox** from the **Secondary Recovery Email**.
|
||||
|
||||
### Role Separation
|
||||
|
||||
| Attribute | Field Name | Example | Purpose & Consumers |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| **Primary Mail** | `mail` | `kiskaadee@roadtotech.me` | **Stalwart Mailbox**, internal homelab communications, Gitea notifications, Git commit author. |
|
||||
| **Recovery Mail** | `recovery_email` | `fcortesbio@gmail.com` | **Authelia Password Resets**, out-of-band security alerts, emergency admin contacts when the homelab server is offline. |
|
||||
|
||||
---
|
||||
|
||||
## How to Implement in LLDAP
|
||||
|
||||
LLDAP supports dynamic user schema extension via its GraphQL API:
|
||||
|
||||
```graphql
|
||||
mutation {
|
||||
addUserAttribute(
|
||||
name: "recovery_email",
|
||||
attributeType: STRING,
|
||||
isList: false,
|
||||
isVisible: true,
|
||||
isEditable: true
|
||||
) {
|
||||
ok
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Result in LLDAP Web UI (`users.roadtotech.me`)
|
||||
When administrators or users view profile settings in `users.roadtotech.me`:
|
||||
- **`Email`**: `kiskaadee@roadtotech.me` (Used by Stalwart Mailbox & LDAP queries).
|
||||
- **`Recovery Email`**: `fcortesbio@gmail.com` (Used for emergency recovery and out-of-band notifications).
|
||||
|
||||
---
|
||||
|
||||
## Configuration Mapping
|
||||
|
||||
### 1. Stalwart Mail Server
|
||||
- **Mailbox User ID**: `uid` (e.g. `kiskaadee`)
|
||||
- **Primary Address**: `mail` (e.g. `kiskaadee@roadtotech.me`)
|
||||
- Stalwart routes all incoming mail for `*@roadtotech.me` to the corresponding user mailbox.
|
||||
|
||||
### 2. Authelia
|
||||
- When configuring Authelia password reset via email (`notifier.smtp`):
|
||||
- Authelia queries LDAP for the user's email.
|
||||
- Can map Authelia's `mail` attribute query to `recovery_email` (or fallback to `mail`).
|
||||
- Password reset links are safely delivered to `fcortesbio@gmail.com` outside of the self-hosted mail infrastructure.
|
||||
|
||||
### 3. Git & Developer Tools (Gitea)
|
||||
- Gitea authenticates against LLDAP and uses `mail` (`kiskaadee@roadtotech.me`) as the primary commit and notification email.
|
||||
@@ -0,0 +1,156 @@
|
||||
---
|
||||
type: discussion
|
||||
project: homelab
|
||||
date: 2026-09-14
|
||||
tags:
|
||||
- homelab
|
||||
- architecture
|
||||
- gitops
|
||||
- workspace
|
||||
---
|
||||
|
||||
# 🏛️ Architecture Analysis: Optimal Placement for Homelab Repositories
|
||||
|
||||
## 1. Context & The Core Dilemma
|
||||
|
||||
Currently, your workstation separates code and system configurations across `$HOME`:
|
||||
* **`~/Config`**: Declarative NixOS workstation configuration (Laptop).
|
||||
* **`~/Brain`**: Obsidian second brain knowledge base.
|
||||
* **`~/Projects/`**: Application development workspaces structured into lifecycle buckets:
|
||||
* `~/Projects/active/` (MagNetFlix, nekoweb, bitetrack-api, Shipwright, etc.)
|
||||
* `~/Projects/learning/` (curso-fastapi)
|
||||
* `~/Projects/archive/` (circulatelo, legacy-bitetrack, etc.)
|
||||
* **`~/Projects/homelab/`** (`Core` server NixOS/Docker/Traefik, `Sites/gitea`, `Sites/jellyfin`, etc.)
|
||||
|
||||
### The Friction Point
|
||||
Homelab repositories are fundamentally **Infrastructure-as-Code (IaC), server daemons, and GitOps deployments**, rather than transient application development code.
|
||||
|
||||
Placing them inside `~/Projects/homelab/` introduces a taxonomy clash: `Projects` organizes items by **lifecycle** (`active`, `learning`, `archive`), but `homelab` is a **functional domain**, not a lifecycle phase. This creates ambiguity:
|
||||
1. Is server infrastructure a "project" that gets archived when completed, or permanent operational infrastructure?
|
||||
2. Why is the workstation OS declared at top-level `~/Config`, while server OS infrastructure lives nested under `~/Projects/homelab/Core`?
|
||||
3. If moved later, what breaks (scripts, search indexing, bookmarks, jumper muscle memory)?
|
||||
|
||||
---
|
||||
|
||||
## 2. Evaluation of Structural Alternatives
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
HOME["$HOME (~)"]
|
||||
|
||||
subgraph "Option A: Dedicated Top-Level (Recommended)"
|
||||
HOME --> CFG["~/Config (Workstation NixOS)"]
|
||||
HOME --> HL["~/Homelab (Server Infrastructure)"]
|
||||
HOME --> BR["~/Brain (Knowledge)"]
|
||||
HOME --> PRJ["~/Projects (Code & Apps)"]
|
||||
|
||||
HL --> HLC["Core/ (Server OS & Engine)"]
|
||||
HL --> HLS["Sites/ (Service Manifests)"]
|
||||
end
|
||||
```
|
||||
|
||||
### Option A: Dedicated Top-Level Directory (`~/Homelab` or `~/Infra`)
|
||||
|
||||
Elevate homelab infrastructure to a peer of `~/Config` and `~/Projects`:
|
||||
```text
|
||||
~
|
||||
├── Brain/
|
||||
├── Config/ # Workstation system declaration
|
||||
├── Homelab/ # Production server infrastructure & GitOps fleet
|
||||
│ ├── Core/ # Server NixOS, Traefik, Docker engine, SOPS secrets
|
||||
│ └── Sites/ # Self-hosted services (gitea, jellyfin, doc2site)
|
||||
└── Projects/ # Software engineering projects
|
||||
├── active/
|
||||
├── learning/
|
||||
└── archive/
|
||||
```
|
||||
|
||||
* **Pros**:
|
||||
* **Architectural Symmetry**: Perfect parity between `~/Config` (client machine) and `~/Homelab` (server fleet).
|
||||
* **Cognitive Clarity**: Zero ambiguity between "writing an application" and "managing live server infrastructure".
|
||||
* **Clean Taxonomic Integrity**: Restores `~/Projects/` to purely lifecycle-based categorization (`active`, `learning`, `archive`).
|
||||
* **Dedicated Navigation**: Direct, first-class jumper shortcuts (e.g. `hl` or `homelab` in `jump.sh`) rather than navigating through project depths.
|
||||
* **Scoped Security & Secrets**: Makes it easy to exclude or strictly restrict tools/LSPs/scanners over secrets-heavy server trees.
|
||||
* **Cons**:
|
||||
* Adds one top-level directory in `~` (bringing total top-level custom folders to 4: `Brain`, `Config`, `Homelab`, `Projects`).
|
||||
|
||||
---
|
||||
|
||||
### Option B: Keep Under Projects (`~/Projects/homelab/`) — The Status Quo
|
||||
|
||||
Maintain `homelab` as a subcategory within `~/Projects/`.
|
||||
|
||||
* **Pros**:
|
||||
* Keeps `$HOME` minimal with fewer top-level directories.
|
||||
* Already indexed by DankSearch (`dsearch`) under `~/Projects`.
|
||||
* No path changes required today.
|
||||
* **Cons**:
|
||||
* **Taxonomic Collision**: Mixes lifecycle buckets (`active/`, `archive/`) with a domain bucket (`homelab/`).
|
||||
* **Search & Tooling Clutter**: Project-wide search scripts (`rg`, `fd`) searching across active dev code also traverse production server docker configs and SOPS secrets.
|
||||
* **Longer Navigation Paths**: Requires typing deeper paths or searching through unrelated application projects.
|
||||
|
||||
---
|
||||
|
||||
### Option C: Lifecycle Placement (`~/Projects/active/homelab/`)
|
||||
|
||||
Move homelab into the active lifecycle directory (`~/Projects/active/homelab/Core`), as was originally referenced in earlier drafts of `architecture.md`.
|
||||
|
||||
* **Pros**:
|
||||
* Adheres strictly to the `active/` lifecycle hierarchy.
|
||||
* **Cons**:
|
||||
* Worst conceptual fit: Homelab is long-lived production infrastructure, not an active dev task that moves to `archive/` upon completion.
|
||||
* Deep directory nesting (`~/Projects/active/homelab/Core`).
|
||||
|
||||
---
|
||||
|
||||
## 3. Comparison Matrix
|
||||
|
||||
| Criteria | Option A: `~/Homelab` | Option B: `~/Projects/homelab` | Option C: `~/Projects/active/homelab` |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| **Conceptual Purity** | **Very High** (Infra vs Code separation) | Medium (Mixed concern) | Low (Infra treated as temp project) |
|
||||
| **Navigation Ergonomics** | **Fast** (`hl` directly to Core/Sites) | Moderate (`pj` with depth 3) | Slow (Deeper nesting) |
|
||||
| **Symmetry with Workstation** | **High** (`~/Config` $\leftrightarrow$ `~/Homelab`) | Low (Asymmetric) | Low (Deeply nested) |
|
||||
| **Search & Secret Isolation** | **Clean** (Independent scoping) | Shared with all dev code | Shared with all active apps |
|
||||
| **Migration Overhead** | Very Low (1 `mv` + 1 symlink) | Zero | Low |
|
||||
|
||||
---
|
||||
|
||||
## 4. Friction-Free Strategy (Decoupled Transition)
|
||||
|
||||
If you are uncertain whether you will want to keep or change the structure in the future, the industry standard technique to prevent friction is the **Symlink Bridge Pattern**:
|
||||
|
||||
```mermaid
|
||||
graph LR
|
||||
PHYSICAL["~/Homelab<br/><i>(Physical Root)</i>"]
|
||||
SYMLINK["~/Projects/homelab<br/><i>(Compatibility Symlink)</i>"]
|
||||
|
||||
SYMLINK -.->|Points to| PHYSICAL
|
||||
|
||||
NAV["Jumper Alias (hl)"] --> PHYSICAL
|
||||
TOOL["Legacy Scripts / Paths"] --> SYMLINK
|
||||
```
|
||||
|
||||
### Why this eliminates all friction:
|
||||
1. **Zero Broken Paths**: Any script, documentation reference, or tool looking for `~/Projects/homelab` continues to work transparently via the filesystem symlink.
|
||||
2. **First-Class Navigation**: You gain a dedicated `hl` (or `homelab`) jumper alias that goes straight to the infrastructure tree.
|
||||
3. **Reversible in Seconds**: If you ever decide you prefer it back inside `~/Projects`, reversing it requires only removing the symlink and moving the folder back.
|
||||
4. **Tooling Agnostic**: DankSearch, Neovim, terminal sessions, and Git operations resolve symlinks seamlessly.
|
||||
|
||||
---
|
||||
|
||||
## 5. Recommended Action Plan
|
||||
|
||||
If you decide to move to the dedicated `~/Homelab` structure:
|
||||
|
||||
1. **Migrate Folder & Establish Bridge**:
|
||||
```bash
|
||||
mv ~/Projects/homelab ~/Homelab
|
||||
ln -s ~/Homelab ~/Projects/homelab
|
||||
```
|
||||
2. **Add Jumper Alias to [`home/shell/jump.sh`](file:///home/kiskaadee/Config/home/shell/jump.sh)**:
|
||||
```bash
|
||||
hl() { jump "$HOME/Homelab" "$1" 2; }
|
||||
homelab() { hl "$@"; }
|
||||
```
|
||||
3. **Update DankSearch Indexing in [`home/desktop.nix`](file:///home/kiskaadee/Config/home/desktop.nix)**:
|
||||
Add `~/Homelab` as an explicit indexed search root so full-text search covers server configs cleanly without traversing symlink loops.
|
||||
@@ -0,0 +1,49 @@
|
||||
---
|
||||
type: discussion
|
||||
project: homelab
|
||||
date: 2026-09-15
|
||||
tags:
|
||||
- homelab
|
||||
- email
|
||||
- hostinger
|
||||
- stalwart
|
||||
---
|
||||
|
||||
# Hostinger Business Email vs. Self-Hosted Stalwart + Relay Architecture
|
||||
|
||||
## 1. Architectural Integration Comparison
|
||||
|
||||
| Criterion | Stalwart Mail Server (+ Brevo/SES Relay) | Hostinger Business Email (SaaS) |
|
||||
|---|---|---|
|
||||
| **Directory Integration** | **Direct LLDAP integration** (`ldap://lldap:3890`). Creating a user in LLDAP automatically provisions their mailbox and credentials. | **None.** Hostinger is a closed proprietary platform; no LDAP, Active Directory, or OIDC sync. Users and passwords must be manually duplicated in Hostinger hPanel. |
|
||||
| **Authentication & SSO** | **Unified credentials** with Authelia, Jellyfin, Gitea, and Nextcloud. One password across the entire homelab. | **Separate credentials.** Users have an independent Hostinger email password distinct from their homelab login. |
|
||||
| **Cost** | **$0 / month.** 100% free (Brevo provides 300 free outgoing emails/day; Stalwart stores data on local server NVMe). | **Pay per mailbox.** ~1,900 CO$/mo (~$0.50/mo) intro rate per user, renewing at 4,900 CO$/mo per user (~$1.20/mo). For 5 users, ~$6/mo. |
|
||||
| **Storage Limits** | **Local disk capacity.** Gigabytes/terabytes limited only by homelab drive storage. | **5 GB per mailbox** (Starter plan). Higher storage tiers cost 3,900–5,900 CO$/mo per user. |
|
||||
| **Alias & User Limits** | **Unlimited** domains, users, and aliases. | **5 aliases & 5 forwarding rules** per mailbox on Starter plan. |
|
||||
| **Homelab Service Alerts** | Native local SMTP submission on Docker `proxy-net` (`stalwart:25/587`). | Any homelab app (Gitea, Authelia, Houston) can authenticate to `smtp.hostinger.com:465` to send emails. |
|
||||
| **Uptime / Power Outages** | Dependent on home power & internet. (If homelab is offline, senders retry automatically for 24–72 hours). | **Cloud-hosted (99.9% uptime).** Mail is received and stored in the cloud regardless of home server status. |
|
||||
| **Maintenance** | Self-managed container updates, volume backups (`./config/stalwart`). | Fully managed by Hostinger; zero server administration. |
|
||||
|
||||
---
|
||||
|
||||
## 2. Can We Connect Current Infrastructure to Hostinger?
|
||||
|
||||
Yes, in the following ways:
|
||||
|
||||
1. **Homelab Notification Outbox (Transactional SMTP):**
|
||||
- We can create a dedicated mailbox in Hostinger (e.g. `notifications@roadtotech.me`).
|
||||
- Authelia, Gitea, Houston, and Homepage can be configured with Hostinger's SMTP (`smtp.hostinger.com:465`) to dispatch system emails, password resets, and commit notifications.
|
||||
2. **Dashboard Webmail Integration:**
|
||||
- Homepage dashboard (`dashboard.roadtotech.me`) can feature a webmail tile pointing to `https://mail.hostinger.com` (or `webmail.roadtotech.me`).
|
||||
3. **What Cannot Be Connected:**
|
||||
- **LLDAP Sync:** You cannot synchronize LLDAP users or passwords into Hostinger.
|
||||
- **Authelia Forward-Auth for Webmail:** Hostinger's webmail runs on Hostinger's infrastructure and cannot be guarded by your local Authelia forward-auth.
|
||||
|
||||
---
|
||||
|
||||
## 3. Engineering Verdict & Recommendation
|
||||
|
||||
- **Stick to Stalwart + Brevo/SES if:**
|
||||
The goal is a cohesive, self-hosted homelab ecosystem where LLDAP serves as the single source of truth for identities, passwords, and mailboxes, with unlimited storage and zero ongoing monthly subscription costs.
|
||||
- **Choose Hostinger Business Email if:**
|
||||
You prioritize having email hosted in the cloud with zero maintenance, 24/7 availability independent of home power/internet outages, and don't mind managing users manually in Hostinger's panel and paying the per-mailbox monthly fee.
|
||||
@@ -0,0 +1,61 @@
|
||||
---
|
||||
type: discussion
|
||||
project: homelab
|
||||
date: 2026-09-15
|
||||
tags:
|
||||
- homelab
|
||||
- email
|
||||
- stalwart
|
||||
- architecture
|
||||
---
|
||||
|
||||
# Mail Server Evaluation for Homelab Core: Why Stalwart is the Modern Standard
|
||||
|
||||
## Executive Summary
|
||||
|
||||
For modern, resource-conscious homelabs running on NixOS and Docker Compose with LLDAP, **Stalwart Mail Server** is currently the best-in-class choice. It replaces the legacy multi-daemon architecture (Postfix + Dovecot + Rspamd + Redis + MariaDB) with a single, memory-safe Rust binary that uses ~50 MB of RAM while supporting both modern protocols (JMAP) and legacy standards (IMAP/SMTP).
|
||||
|
||||
---
|
||||
|
||||
## Comparison of Self-Hosted Mail Solutions
|
||||
|
||||
| Feature | Stalwart Mail | Mailcow (dockerized) | docker-mailserver | Mail-in-a-Box |
|
||||
| :--- | :--- | :--- | :--- | :--- |
|
||||
| **Architecture** | **Single binary (Rust)** | 12–15 microservices | Bundled daemons (Postfix/Dovecot) | Full OS takeover (Ubuntu) |
|
||||
| **RAM Footprint** | **~50–80 MB** | 3.5–5.0 GB | ~800 MB – 1.5 GB | ~1.5 GB |
|
||||
| **LLDAP Native Support** | **First-class directory** | Via complex LDAP pass-through | Via dovecot-ldap.conf | ❌ Local SQLite/flat |
|
||||
| **Protocols** | **JMAP + IMAP4 + SMTP** | IMAP4 + SMTP (SOGo) | IMAP4 + SMTP | IMAP4 + SMTP |
|
||||
| **Spam / Security Engine** | Built-in Rust engine | Rspamd + ClamAV + Redis | Rspamd / SpamAssassin | SpamAssassin |
|
||||
| **Traefik Compatibility** | Seamless | ⚠️ Clashes with external proxy | Seamless | ❌ Takes over Port 80/443 |
|
||||
| **Backup Simplicity** | Single data volume + SQLite/S3 | Multiple volumes + MySQL dump | Multiple config & mail volumes | Duplicity backup |
|
||||
|
||||
---
|
||||
|
||||
## Why Stalwart Fits the Roadtotech Homelab Architecture
|
||||
|
||||
### 1. Architectural Synergy with LLDAP
|
||||
Stalwart was designed with modern directory services in mind. It pairs with LLDAP out of the box:
|
||||
- Point Stalwart's directory provider to `ldap://lldap:3890` with base DN `dc=roadtotech,dc=me`.
|
||||
- Accounts created in `users.roadtotech.me` immediately receive mailboxes and authenticate seamlessly.
|
||||
|
||||
### 2. Next-Gen JMAP Protocol
|
||||
In addition to standard IMAP/SMTP for apps like Thunderbird, Apple Mail, and Outlook, Stalwart supports **JMAP** (RFC 8620) — the modern REST/JSON mail protocol created by Fastmail. JMAP provides instant synchronization, push notifications, and consumes 90% less battery and data on mobile devices.
|
||||
|
||||
### 3. All-in-One Engine
|
||||
Traditional mail stacks require maintaining 5+ distinct configuration syntaxes (Postfix `main.cf`, Dovecot `dovecot.conf`, Rspamd Lua rules, OpenDKIM, Sieve). Stalwart unifies SMTP routing, IMAP storage, DKIM signing, ARC, SPF, DMARC validation, and spam filtering into a single declarative configuration file (`stalwart.toml`) or Web Admin UI.
|
||||
|
||||
---
|
||||
|
||||
## The Reality of Homelab Email Deliverability
|
||||
|
||||
When hosting email on a homelab connection (residential or small business ISP):
|
||||
|
||||
1. **Inbound Mail (Receiving)**:
|
||||
- Works flawlessly. Traefik or direct host port mappings forward inbound Port 25 to Stalwart.
|
||||
2. **Outbound Mail (Sending)**:
|
||||
- **The Challenge**: Almost all residential IP ranges are on Spamhaus's Policy Block List (PBL). Major providers (Gmail, Microsoft 365, Yahoo) reject or quarantine mail sent directly from residential IP pools to prevent malware botnets from spamming.
|
||||
- **The Solution (SMTP Relay / Smart Host)**:
|
||||
- Configure Stalwart to route outgoing mail through an authenticated SMTP relay:
|
||||
- **AWS SES (Simple Email Service)**: Free tier covers 3,000 emails/month; otherwise $0.10 per 10,000 emails.
|
||||
- **Brevo (Sendinblue) / SendGrid**: 300 free emails/day.
|
||||
- Stalwart manages your DKIM signing locally, so the email is cryptographically signed by `roadtotech.me`, but safely relayed through clean IP pools with 99.9% inbox deliverability.
|
||||
@@ -0,0 +1,99 @@
|
||||
---
|
||||
type: discussion
|
||||
project: homelab
|
||||
date: 2026-09-14
|
||||
tags:
|
||||
- homelab
|
||||
- homepage
|
||||
- courses
|
||||
- multirepo
|
||||
---
|
||||
|
||||
# Architecture Plan: Multirepo Refactor of Homepage & Learning Hub
|
||||
|
||||
## Executive Summary
|
||||
This document analyzes and outlines the execution plan for disentangling **Homepage** from the **Learning Hub** (`courses` API & Kanban board).
|
||||
|
||||
### Verdict: Is this the right direction?
|
||||
**Yes, strongly affirmative.**
|
||||
- **Homepage** is an administrative and operational dashboard coupled to Core infrastructure (`socket-proxy`, `socket-net`, `traefik`, host system resource widgets). It belongs in `/home/kiskaadee/Homelab/Core`.
|
||||
- **Courses** (the learning API & Kanban) is a discrete user-domain application with its own database (Turso/LibSQL), domain logic, and frontend requirements. It belongs in `/home/kiskaadee/Homelab/Sites/courses`.
|
||||
- **Decoupling eliminates technical debt**: Injecting the learning Kanban into Homepage via `custom.js` and `custom.css` with DOM mutations (`MutationObserver`) was an architectural anti-pattern. Decoupling allows Homepage to remain fast and standard, while providing Courses with a dedicated standalone web UI.
|
||||
|
||||
---
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
subgraph Current Coupled State
|
||||
SitesDash["Sites/dashboard"]
|
||||
HP1["Homepage Container"]
|
||||
LearnAPI1["Learning API Container"]
|
||||
CustomJS["custom.js / custom.css (DOM Injection Hack)"]
|
||||
SitesDash --> HP1
|
||||
SitesDash --> LearnAPI1
|
||||
HP1 -.->|"MutationObserver"| CustomJS
|
||||
CustomJS -->|"Fetch courses"| LearnAPI1
|
||||
end
|
||||
|
||||
subgraph Target Decoupled Architecture
|
||||
subgraph CoreInfra [Homelab Core]
|
||||
CoreCompose["Core/docker-compose.yml"]
|
||||
HP2["Homepage (Core Portal)"]
|
||||
SocketProxy["socket-proxy:2375"]
|
||||
Appctl["appctl sync"]
|
||||
CoreCompose --> HP2
|
||||
HP2 -->|"Reads container status"| SocketProxy
|
||||
Appctl -->|"Generates services.yaml"| HP2
|
||||
end
|
||||
|
||||
subgraph SitesApps [Homelab Sites]
|
||||
CoursesSite["Sites/courses"]
|
||||
CoursesApp["Courses Container (FastAPI + Standalone UI)"]
|
||||
Turso[(Turso Cloud / SQLite)]
|
||||
CoursesSite --> CoursesApp
|
||||
CoursesApp --> Turso
|
||||
end
|
||||
|
||||
HP2 -->|"Navigation Link"| CoursesApp
|
||||
end
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Migration Phases
|
||||
|
||||
### Phase 1: Establish `Homelab/Sites/courses`
|
||||
1. Move the backend code from `Sites/dashboard/learning/` to `Sites/courses/`:
|
||||
- `app/` (models, database, controllers, routes, main, config)
|
||||
- `tests/` (removing legacy `test_system_stats` and `test_bookmarks` tests that belonged to the old dashboard prototype)
|
||||
- `Dockerfile`, `pyproject.toml` (pinning Python 3.11 for `libsql-experimental` prebuilt wheels), `uv.lock`, `.dockerignore`, `.env-example`, `README.md`
|
||||
2. Create a clean standalone frontend for the Kanban board in `app/static/`:
|
||||
- `index.html`, `style.css`, `app.js` (clean extraction from the battle-tested `custom.js` & `custom.css`).
|
||||
- Mount static directory at `/` in FastAPI (`app.mount("/", StaticFiles(directory="app/static", html=True))`) with `/api/courses` routes.
|
||||
3. Add `app.yaml`:
|
||||
- Name: `courses`, domain: `courses.roadtotech.me`, group: `Knowledge & Notes`, container: `courses`.
|
||||
4. Add `docker-compose.yml`:
|
||||
- Attached to `proxy-net`, Traefik labels for router, service port 8000, HTTPS redirect.
|
||||
5. Add `UNLICENSE` and initialize commit in `homelab-courses` git repository.
|
||||
|
||||
### Phase 2: Reintegrate Homepage into `Homelab/Core`
|
||||
1. Copy Homepage configuration into `Core/config/homepage/`:
|
||||
- `bookmarks.yaml`, `docker.yaml` (`host: socket-proxy`), `settings.yaml`, `widgets.yaml`, brand assets (`houston.png`, `houston.svg`).
|
||||
- Remove custom Kanban DOM-injection JS/CSS.
|
||||
2. Add `homepage` service into `Core/docker-compose.yml`:
|
||||
- Networks: `socket-net`, `proxy-net`.
|
||||
- Host routing: `dashboard.${DOMAIN}` on port 3000.
|
||||
3. Update `Core/scripts/appctl_engine.py`:
|
||||
- Target `Core/config/homepage/services.yaml` for `appctl sync`.
|
||||
4. Update `Core/tests/structural/test_repository_structure.py` and run test suite.
|
||||
|
||||
### Phase 3: Service Synchronization & Verification
|
||||
1. Run `appctl sync` to ensure `courses` from `Sites/courses/app.yaml` is discovered and compiled into Homepage.
|
||||
2. Validate configurations: `appctl config courses` and `appctl config core`.
|
||||
3. Run automated tests across both repositories.
|
||||
|
||||
### Phase 4: Retire `Sites/dashboard`
|
||||
1. Stop running containers in `Sites/dashboard`.
|
||||
2. Clean up or archive `homelab-dashboard` on Gitea.
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
type: guide
|
||||
project: homelab
|
||||
tags:
|
||||
- homelab
|
||||
- homepage
|
||||
- core
|
||||
- dashboard
|
||||
---
|
||||
|
||||
# Walkthrough: Homepage Reintegration into Homelab Core
|
||||
|
||||
## Overview
|
||||
We have extracted **Homepage** (`gethomepage`) from the temporary hybrid `Sites/dashboard` repository and reintegrated it as a first-class service in [Homelab/Core](/home/kiskaadee/Homelab/Core).
|
||||
|
||||
---
|
||||
|
||||
## Changes Implemented
|
||||
|
||||
### 1. Reintegrated Clean Configuration
|
||||
- **Location**: `/home/kiskaadee/Homelab/Core/config/homepage/`
|
||||
- **Assets Migrated**:
|
||||
- `bookmarks.yaml`: Personal project and social quicklinks
|
||||
- `docker.yaml`: Direct connection to `socket-proxy:2375`
|
||||
- `settings.yaml`, `widgets.yaml`: Core system info widgets (CPU, Memory, Search)
|
||||
- `houston.png`, `houston.svg`, `kubernetes.yaml`, `proxmox.yaml`, `services.yaml.example`
|
||||
- **Removed Tech Debt**: Completely omitted `custom.js` and `custom.css` (the fragile `MutationObserver` DOM injection hacks used previously to insert the learning Kanban board).
|
||||
|
||||
### 2. Core Compose Definition
|
||||
- **File**: `Homelab/Core/docker-compose.yml`
|
||||
- Added `homepage` service attached to `socket-net` (for container discovery) and `proxy-net` (for Traefik ingress).
|
||||
- Configured Traefik TLS router for `dashboard.${DOMAIN}` with automatic HTTP-to-HTTPS redirect.
|
||||
|
||||
### 3. Orchestrator (`appctl`) Updates
|
||||
- **File**: `Homelab/Core/scripts/appctl_engine.py`
|
||||
- Registered `homepage` as an official Core service under `get_core_services()`.
|
||||
- Updated `cmd_sync_homepage` so `appctl sync` outputs directly to `Core/config/homepage/services.yaml`.
|
||||
- **File**: `Homelab/Core/.gitignore`
|
||||
- Added `config/homepage/services.yaml` to gitignore (since it is compiled dynamically).
|
||||
- **File**: `Homelab/Core/README.md`
|
||||
- Updated manifest documentation to reflect the new services path.
|
||||
|
||||
### 4. Structural Tests
|
||||
- **File**: `Homelab/Core/tests/structural/test_repository_structure.py`
|
||||
- Added `config/homepage` to `required_paths`.
|
||||
|
||||
---
|
||||
|
||||
## Verification & Results
|
||||
|
||||
1. **Test Suite**:
|
||||
```bash
|
||||
uv run --with pytest --with pyyaml pytest tests
|
||||
# 35 passed in 0.18s
|
||||
```
|
||||
2. **Orchestrator Sync**:
|
||||
```bash
|
||||
appctl sync
|
||||
# ✨ Homepage synchronized successfully (4 visible apps in 4 groups)
|
||||
# 📄 Generated /home/kiskaadee/Homelab/Core/config/homepage/services.yaml
|
||||
```
|
||||
3. **Core Service Listing**:
|
||||
```bash
|
||||
appctl list --core
|
||||
# homepage is now listed under CORE SERVICE pointing to ~/Homelab/Core
|
||||
```
|
||||
4. **Compose Syntax Validation**:
|
||||
```bash
|
||||
docker compose -f /home/kiskaadee/Homelab/Core/docker-compose.yml config
|
||||
# Configuration verified valid
|
||||
```
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
type: guide
|
||||
project: homelab
|
||||
tags:
|
||||
- homelab
|
||||
- lldap
|
||||
- authelia
|
||||
- auth
|
||||
- gitops
|
||||
---
|
||||
|
||||
# LLDAP + Authelia Integration & Pre-Commit Quality Gate Walkthrough
|
||||
|
||||
## Summary of Completed Implementations
|
||||
|
||||
### 1. Repository Tests in Pre-Commit Hook
|
||||
- **Hook Location**: [`.githooks/pre-commit`](file:///home/kiskaadee/Homelab/Core/.githooks/pre-commit) (executable, tracked in git).
|
||||
- **Git Hooks Path**: Configured via `git config core.hooksPath .githooks` on both local dev and production server environments.
|
||||
- **Flake Integration**: [`flake.nix`](file:///home/kiskaadee/Homelab/Core/flake.nix#L35-L37) now includes a `shellHook` that automatically ensures `core.hooksPath` is registered whenever entering the Nix development shell.
|
||||
- **Structural Invariant Test**: Added `.githooks/pre-commit` presence and executable bit verification in [`tests/structural/test_repository_structure.py`](file:///home/kiskaadee/Homelab/Core/tests/structural/test_repository_structure.py#L29-L39).
|
||||
- **Verification**: Verified automatically on `git commit` — executes Ruff linter and the full 35 Pytest invariant tests in ~0.12s before allowing commits.
|
||||
|
||||
---
|
||||
|
||||
### 2. LLDAP Service & Dynamic User Backend
|
||||
- **Service Container**: `nitnelave/lldap:stable` deployed in [`docker-compose.yml`](file:///home/kiskaadee/Homelab/Core/docker-compose.yml#L102-L133) on `proxy-net`.
|
||||
- **Public Admin & Self-Service UI**: [https://users.roadtotech.me](https://users.roadtotech.me) (secured with Traefik TLS ACME certificate).
|
||||
- **Internal LDAP Endpoint**: `ldap://lldap:3890` with Base DN `dc=roadtotech,dc=me`.
|
||||
- **Decoupled SOPS Secrets**:
|
||||
- `LLDAP_JWT_SECRET`
|
||||
- `LLDAP_KEY_SEED`
|
||||
- `LLDAP_LDAP_USER_PASS` / `AUTHELIA_LDAP_PASSWORD`
|
||||
- Added to encrypted [`nixos/secrets.yaml`](file:///home/kiskaadee/Homelab/Core/nixos/secrets.yaml) and exposed via [`nixos/modules/homeserver.nix`](file:///home/kiskaadee/Homelab/Core/nixos/modules/homeserver.nix).
|
||||
|
||||
---
|
||||
|
||||
### 3. Authelia LDAP Reconfiguration
|
||||
- **Backend Switched**: [`config/authelia/configuration.yml`](file:///home/kiskaadee/Homelab/Core/config/authelia/configuration.yml#L10-L28) replaced the static `file` backend with `ldap` pointing to `ldap://lldap:3890`.
|
||||
- **Users File Removed**: Removed `/run/secrets/rendered/users.yml:/config/users.yml:ro` mount from Authelia.
|
||||
- **Bypass Rule**: Added `users.{{ env "DOMAIN" }}` to Authelia's bypass list so users can access LLDAP's login and self-service portal directly.
|
||||
- **Appctl Integration**: Registered `lldap` under **Core Infrastructure** in [`scripts/appctl_engine.py`](file:///home/kiskaadee/Homelab/Core/scripts/appctl_engine.py#L328) and Homepage dashboard card (`lldap.png` icon).
|
||||
|
||||
---
|
||||
|
||||
### 4. Directory Seeding & Verification
|
||||
- Created [`scripts/bootstrap_lldap_users.py`](file:///home/kiskaadee/Homelab/Core/scripts/bootstrap_lldap_users.py).
|
||||
- Groups created in LLDAP: `admins`, `dev`, `users`.
|
||||
- Users migrated:
|
||||
- `kiskaadee` (`fcortesbio@gmail.com`) -> Groups: `admins`, `dev`
|
||||
- `misa` (`icdf0728@gmail.com`) -> Groups: `users`
|
||||
- `valenvg` (`vegavalentina069@gmail.com`) -> Groups: `users`
|
||||
- **Live Authelia Authentication Test**:
|
||||
- `POST https://auth.roadtotech.me/api/firstfactor` verified in real time: returns `{"status":"OK"}` for valid LLDAP credentials and rejects invalid passwords.
|
||||
|
||||
---
|
||||
|
||||
## Managing Users Going Forward (Zero Secrets Touched)
|
||||
|
||||
### Web Interface
|
||||
Navigate to **[https://users.roadtotech.me](https://users.roadtotech.me)**:
|
||||
1. Log in as `admin` (or as user `kiskaadee` with admin privileges).
|
||||
2. **Add User**: Click **Add user**, enter display name, username, and email.
|
||||
3. **Assign Groups**: Assign `admins`, `dev`, or `users` with checkboxes.
|
||||
4. **Reset/Set Passwords**: Click on the user -> **Change password** or send an invitation link.
|
||||
5. Changes take effect in Authelia **immediately** with zero downtime and without modifying any git files or SOPS secrets.
|
||||
|
||||
### CLI Password Reset
|
||||
To set/reset any user's password from the server terminal:
|
||||
```bash
|
||||
docker exec lldap /app/lldap_set_password \
|
||||
--base-url http://localhost:17170 \
|
||||
--admin-username admin \
|
||||
--admin-password <ADMIN_PASSWORD> \
|
||||
--username <USERNAME> \
|
||||
--password <NEW_PASSWORD>
|
||||
```
|
||||
@@ -0,0 +1,112 @@
|
||||
---
|
||||
type: guide
|
||||
project: homelab
|
||||
tags:
|
||||
- homelab
|
||||
- email
|
||||
- deliverability
|
||||
- brevo
|
||||
- dns
|
||||
---
|
||||
|
||||
# Mail Deliverability Guide: Solving Dynamic IPs, Missing rDNS (PTR), and Spamhaus PBL
|
||||
|
||||
## 1. The Core Problem: Why Residential IPs Land in Spam
|
||||
|
||||
Your concern is 100% accurate: **Attempting to send outbound email directly from a residential or dynamic IP to major providers (Gmail, Outlook, Yahoo, Apple) is virtually guaranteed to fail or go to spam.**
|
||||
|
||||
Here is what receiving mail servers check when a connection arrives on port 25:
|
||||
|
||||
1. **Forward-Confirmed Reverse DNS (FCrDNS / PTR):**
|
||||
- The receiving MTA checks the connecting IP (`186.168.147.225`) and looks up its PTR record.
|
||||
- It expects the PTR to resolve to the server's FQDN (e.g., `mail.roadtotech.me`), and for `mail.roadtotech.me` to resolve back to that exact same IP.
|
||||
- Residential ISPs do not permit custom PTR configuration on consumer dynamic lines; they either return `NXDOMAIN` or a generic residential hostname (e.g., `cpe-186-168-xxx.isp.net`).
|
||||
2. **Policy Block List (Spamhaus PBL & RBLs):**
|
||||
- Almost every residential dynamic IP block in the world is pre-emptively listed on Spamhaus PBL (Policy Block List) and similar spam databases.
|
||||
- Major providers (Google, Microsoft) query Spamhaus PBL on the connecting IP. If listed, they reject with `550 5.7.1 Service unavailable; Client host [...] blocked using Spamhaus`.
|
||||
|
||||
---
|
||||
|
||||
## 2. Inbound vs. Outbound: The Asymmetry of Email
|
||||
|
||||
Email delivery is fundamentally asymmetrical:
|
||||
|
||||
| Direction | What Happens | Is PTR / rDNS Required? | Is Static IP Required? |
|
||||
|---|---|---|---|
|
||||
| **Inbound** (Receiving mail from others) | A sender (e.g. Gmail) looks up your `MX` record (`mail.roadtotech.me`) and connects to your port 25. | **NO**. Your server never presents PTR; you are the *listener*. | **NO**. As long as dynamic DNS (Dynu) points `mail.roadtotech.me` to your current IP, inbound mail arrives normally. |
|
||||
| **Outbound** (Sending mail to others) | Your server connects to Gmail's port 25 (`gmail-smtp-in.l.google.com`). | **YES**. Gmail inspects *your* connecting IP for valid PTR and PBL status. | **YES**. Sending directly from dynamic residential IP causes immediate rejection. |
|
||||
|
||||
---
|
||||
|
||||
## 3. The Proven Solutions
|
||||
|
||||
There are two production-grade patterns homelabs use to achieve **10/10 deliverability (zero spam flag)** without an enterprise ISP static line:
|
||||
|
||||
### Pattern A: The Smart Host Relay (Recommended — Free & No VPS Needed)
|
||||
|
||||
Stalwart acts as your complete private mail server (storing emails, providing IMAP/JMAP mailboxes to your phone and computer), but uses an **authenticated outbound relay (Smart Host)** for sending external emails.
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph Homelab ["Homelab (Dynamic IP)"]
|
||||
Client["Email Client<br/>(Thunderbird / Phone)"]
|
||||
Stalwart["Stalwart Mail Server<br/>• Stores Mailboxes (IMAP/JMAP)<br/>• Signs with your Domain DKIM"]
|
||||
end
|
||||
|
||||
subgraph Outbound ["Smart Host Relay (Static IP + Clean PTR)"]
|
||||
Relay["Brevo / Amazon SES<br/>• Static Enterprise IP<br/>• Clean rDNS (PTR)<br/>• SPF: include:spf.brevo.com"]
|
||||
end
|
||||
|
||||
subgraph Recipient ["Recipient"]
|
||||
Gmail["Gmail / Outlook MTA<br/>Checks: SPF ✓ DKIM ✓ DMARC ✓<br/>Placement: INBOX"]
|
||||
end
|
||||
|
||||
Client -->|Submit| Stalwart
|
||||
Stalwart -->|Encrypted TLS (587)| Relay
|
||||
Relay -->|Delivers| Gmail
|
||||
```
|
||||
|
||||
#### Why This Gives 100% Inbox Placement:
|
||||
1. **DKIM:** Stalwart signs the outgoing email with your private key for `roadtotech.me`. The cryptographic signature proves you wrote it.
|
||||
2. **SPF:** Your DNS SPF record includes the relay (`v=spf1 mx include:spf.brevo.com ~all`).
|
||||
3. **DMARC:** Passes with flying colors because DKIM aligns with `roadtotech.me`.
|
||||
4. **Connecting IP:** Gmail sees the email coming from the relay's IP (which has clean rDNS and zero PBL listings). Your residential dynamic IP is **never exposed** or penalized.
|
||||
5. **Cost:**
|
||||
- **Brevo (Sendinblue):** Free tier allows **300 emails/day** (9,000/month) with zero cost.
|
||||
- **Amazon SES:** **10,000 emails/month** free or $0.10/10k.
|
||||
|
||||
---
|
||||
|
||||
### Pattern B: The VPS WireGuard Gateway (100% Self-Hosted — ~$3/mo)
|
||||
|
||||
If you strictly do not want any third-party relay touching your outbound emails:
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph Homelab ["Homelab (Dynamic IP)"]
|
||||
Stalwart["Stalwart Mail Server"]
|
||||
end
|
||||
|
||||
subgraph Cloud ["Cloud VPS ($3/mo - Hetzner / RackNerd)"]
|
||||
VPS["VPS Gateway<br/>• Dedicated Static IP<br/>• Custom PTR: mail.roadtotech.me<br/>• WireGuard Tunnel"]
|
||||
end
|
||||
|
||||
subgraph Internet ["Public Internet"]
|
||||
World["External Mail Servers"]
|
||||
end
|
||||
|
||||
Stalwart <==>|Encrypted WireGuard Tunnel| VPS
|
||||
VPS <==>|Port 25 (In & Out)| World
|
||||
```
|
||||
|
||||
1. Rent a cheap cloud VPS (Hetzner Cloud ~$3.50/mo or RackNerd ~$15/yr) that provides a static IPv4 and allows setting custom rDNS (PTR).
|
||||
2. Set the VPS PTR record to `mail.roadtotech.me`.
|
||||
3. Establish a WireGuard tunnel between the VPS and your homelab server.
|
||||
4. Route port 25 traffic (both inbound and outbound) through the VPS tunnel.
|
||||
|
||||
---
|
||||
|
||||
## 4. Summary & Recommendation
|
||||
|
||||
- If you don't want to pay for or manage a VPS: **Pattern A (Stalwart + Free Brevo/SES Outbound Relay)** is the gold standard. You get full self-hosted privacy for storage, IMAP, and JMAP, while piggybacking on enterprise deliverability for outbound emails.
|
||||
- If you want absolute sovereignty without any intermediary: **Pattern B (VPS WireGuard Gateway)** gives you a dedicated static IP and custom PTR for ~$3/month.
|
||||
@@ -28,6 +28,12 @@ At server boot, the `sops-nix` systemd module decrypts these secrets and renders
|
||||
|
||||
## 👤 Adding or Modifying Authelia Users
|
||||
|
||||
> [!NOTE]
|
||||
> **Dynamic User Management via LLDAP:**
|
||||
> User provisioning is now dynamically handled via the self-hosted **LLDAP** service at `https://users.roadtotech.me`. You no longer need to edit Nix declarations or regenerate SOPS secrets for user additions. See [LLDAP + Authelia Integration](lldap-authelia-integration.md) for details.
|
||||
>
|
||||
> The static SOPS procedure below is preserved for reference or fallback recovery accounts.
|
||||
|
||||
Authelia users are declared declaratively in `~/Core/nixos/modules/homeserver.nix`, while their password hashes are stored encrypted in `nixos/secrets.yaml`.
|
||||
|
||||
### Step 1: Generate an Argon2 Password Hash
|
||||
|
||||
@@ -0,0 +1,259 @@
|
||||
---
|
||||
type: plan
|
||||
status: completed
|
||||
project: homelab
|
||||
tags:
|
||||
- homelab
|
||||
- homepage
|
||||
- courses
|
||||
- multirepo
|
||||
---
|
||||
|
||||
# Implementation Plan: Multirepo Refactor of Homepage & Learning Hub
|
||||
|
||||
## Goal Description
|
||||
Restructure the homelab services by disentangling the **Homepage** dashboard from the **Learning Hub** (courses API & Kanban board):
|
||||
1. **Reintegrate Homepage into Homelab Core** (`/home/kiskaadee/Homelab/Core`): Return Homepage to its natural role as the central infrastructure portal and container status monitor in the Core stack, removing custom DOM-injection scripts (`custom.js`, `custom.css`).
|
||||
2. **Establish Standalone Courses App** (`/home/kiskaadee/Homelab/Sites/courses`): Promote the learning API and its Kanban board into an independent application under `Sites/courses`, equipped with its own `app.yaml`, standalone frontend UI, Turso database connection, and isolated lifecycle.
|
||||
3. **Update Orchestrator (`appctl`)**: Direct `appctl sync` to output Homepage configuration to `Core/config/homepage/services.yaml`, ensuring dynamic discovery of all `Sites/*/app.yaml` manifests including the new `courses` site.
|
||||
4. **Decommission `Sites/dashboard`**: Safely transition and retire the deprecated `Sites/dashboard` repository.
|
||||
|
||||
---
|
||||
|
||||
## Architectural Evaluation: Is This the Right Direction?
|
||||
|
||||
**Yes, this refactoring is strongly recommended.**
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
subgraph Current Architecture [Current Coupled State]
|
||||
SitesDash["Sites/dashboard (homelab-dashboard repo)"]
|
||||
HP1["Homepage Container"]
|
||||
LearnAPI1["Learning API Container"]
|
||||
CustomJS["custom.js / custom.css (DOM Injection Hack)"]
|
||||
SitesDash --> HP1
|
||||
SitesDash --> LearnAPI1
|
||||
HP1 -.->|"MutationObserver\nDOM Injection"| CustomJS
|
||||
CustomJS -->|"Fetch courses"| LearnAPI1
|
||||
end
|
||||
|
||||
subgraph Target Architecture [Target Decoupled State]
|
||||
subgraph CoreInfra [Homelab Core]
|
||||
CoreCompose["Core/docker-compose.yml"]
|
||||
HP2["Homepage (Core Portal)"]
|
||||
SocketProxy["socket-proxy:2375"]
|
||||
Appctl["appctl sync"]
|
||||
CoreCompose --> HP2
|
||||
HP2 -->|"Reads container status"| SocketProxy
|
||||
Appctl -->|"Generates services.yaml"| HP2
|
||||
end
|
||||
|
||||
subgraph SitesApps [Homelab Sites]
|
||||
CoursesSite["Sites/courses (homelab-courses repo)"]
|
||||
CoursesApp["Courses Container (FastAPI + Standalone UI)"]
|
||||
Turso[(Turso Cloud / SQLite)]
|
||||
CoursesSite --> CoursesApp
|
||||
CoursesApp --> Turso
|
||||
end
|
||||
|
||||
HP2 -->|"Navigation Link"| CoursesApp
|
||||
end
|
||||
```
|
||||
|
||||
### Key Rationale
|
||||
1. **Separation of Infrastructure vs. Domain Application**:
|
||||
- **Homepage** is an operational monitoring tool tightly coupled to `socket-net` (via `socket-proxy:2375`) and the host's container lifecycle. It lists containers, inspects CPU/RAM/Disk, and aggregates links. It belongs squarely inside `Core`.
|
||||
- **Learning Hub / Courses** is a personal domain application with its own database (Turso/LibSQL), schemas, business logic, and UI. It does not need socket access or cluster privileges.
|
||||
2. **Elimination of Frontend Anti-Patterns**:
|
||||
- Injecting a Kanban board into Homepage via `custom.js` with `MutationObserver` polling and arbitrary HTML string templates was a fragile workaround.
|
||||
- Giving `courses` a dedicated frontend (served directly alongside the API) creates a clean, testable user interface without cross-origin hacks or layout collisions.
|
||||
3. **Consistency with the Homelab Specification**:
|
||||
- Every application in `Sites/` must be self-describing via `app.yaml` and discoverable by `appctl`. In the current setup, `dashboard` was an anomaly (`visible: false`, dual containers, special-cased in `appctl_engine.py`).
|
||||
- Moving Homepage into Core allows `appctl sync` to treat all `Sites/*` uniformly.
|
||||
|
||||
---
|
||||
|
||||
## User Review Required
|
||||
|
||||
> [!IMPORTANT]
|
||||
> **Domain Names & Routing**:
|
||||
> - Currently, `Sites/dashboard` used `dashboard.roadtotech.me` for Homepage and `learning.roadtotech.me` for the learning API.
|
||||
> - In the new layout:
|
||||
> - Homepage in Core will serve `dashboard.roadtotech.me`.
|
||||
> - Courses in `Sites/courses` can serve `courses.roadtotech.me` (with an alias for `learning.roadtotech.me` if desired).
|
||||
> - Please confirm if you prefer `courses.roadtotech.me` or `learning.roadtotech.me` as the primary domain for the courses app.
|
||||
|
||||
> [!NOTE]
|
||||
> **Frontend Implementation for Courses**:
|
||||
> We propose serving a clean, responsive standalone Kanban board (extracted and modernized from `custom.js` / `custom.css`) directly from FastAPI via `StaticFiles` at `/` while the API lives at `/api/courses`. This avoids needing a separate Node.js build step or container, maintaining zero-overhead single-container deployment.
|
||||
|
||||
---
|
||||
|
||||
## Proposed Changes
|
||||
|
||||
### Component 1: `Homelab/Sites/courses` (New Application Repository)
|
||||
|
||||
#### [NEW] `Sites/courses/app.yaml`
|
||||
Declare metadata for the courses service:
|
||||
```yaml
|
||||
name: "courses"
|
||||
aliases:
|
||||
- "learning"
|
||||
domain: "courses.roadtotech.me"
|
||||
description: "Learning Path & Course Tracking Kanban Hub"
|
||||
visible: true
|
||||
auth: false
|
||||
networks:
|
||||
- proxy-net
|
||||
homepage:
|
||||
title: "Courses"
|
||||
group: "Knowledge & Notes"
|
||||
icon: "school.png"
|
||||
container: "courses"
|
||||
weight: 20
|
||||
```
|
||||
|
||||
#### [NEW] `Sites/courses/docker-compose.yml`
|
||||
Standard container stack adhering to Homelab Sites conventions:
|
||||
```yaml
|
||||
services:
|
||||
courses:
|
||||
build: .
|
||||
container_name: ${CONTAINER_NAME:-courses}
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
environment:
|
||||
- TURSO_DATABASE_URL=${TURSO_DATABASE_URL}
|
||||
- TURSO_AUTH_TOKEN=${TURSO_AUTH_TOKEN}
|
||||
- PORT=8000
|
||||
networks:
|
||||
- proxy
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
# HTTPS Router
|
||||
- "traefik.http.routers.${CONTAINER_NAME:-courses}.rule=Host(`${SERVICE_DOMAIN:-courses.roadtotech.me}`)"
|
||||
- "traefik.http.routers.${CONTAINER_NAME:-courses}.entrypoints=websecure"
|
||||
- "traefik.http.routers.${CONTAINER_NAME:-courses}.tls=true"
|
||||
- "traefik.http.routers.${CONTAINER_NAME:-courses}.service=${CONTAINER_NAME:-courses}-svc"
|
||||
# HTTP to HTTPS Redirect
|
||||
- "traefik.http.routers.${CONTAINER_NAME:-courses}-red.rule=Host(`${SERVICE_DOMAIN:-courses.roadtotech.me}`)"
|
||||
- "traefik.http.routers.${CONTAINER_NAME:-courses}-red.entrypoints=web"
|
||||
- "traefik.http.routers.${CONTAINER_NAME:-courses}-red.middlewares=https-redirect@docker"
|
||||
# Service Port
|
||||
- "traefik.http.services.${CONTAINER_NAME:-courses}-svc.loadbalancer.server.port=8000"
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
name: ${PROXY_NETWORK:-proxy-net}
|
||||
external: true
|
||||
```
|
||||
|
||||
#### [NEW] Migrate Application Code & Static Frontend
|
||||
- Copy `app/`, `tests/`, `docs/`, `Dockerfile`, `pyproject.toml`, `uv.lock`, `.dockerignore`, and `.env-example` from `Sites/dashboard/learning/` to `Sites/courses/`.
|
||||
- Add `app/static/` containing standalone `index.html`, `style.css`, and `app.js` derived from the existing Kanban UI logic.
|
||||
- Update `app/main.py` to mount `app/static` at `/` while serving `/api/courses`.
|
||||
- Add `UNLICENSE` (maintaining Homelab license invariant) and `README.md`.
|
||||
|
||||
---
|
||||
|
||||
### Component 2: `Homelab/Core` (Reintegration of Homepage)
|
||||
|
||||
#### [NEW] `Core/config/homepage/`
|
||||
- Transfer configuration files from `Sites/dashboard/config/`:
|
||||
- `bookmarks.yaml`
|
||||
- `docker.yaml` (configured to connect to `host: socket-proxy`, `port: 2375`)
|
||||
- `settings.yaml`
|
||||
- `widgets.yaml`
|
||||
- Icons and brand assets (`houston.png`, `houston.svg`)
|
||||
- Do **not** include `custom.js` or `custom.css` (or leave them empty), keeping Homepage clean.
|
||||
|
||||
#### [MODIFY] `Core/docker-compose.yml`
|
||||
Add the `homepage` service to the core stack:
|
||||
```yaml
|
||||
homepage:
|
||||
image: ghcr.io/gethomepage/homepage:latest
|
||||
container_name: homepage
|
||||
restart: always
|
||||
volumes:
|
||||
- ./config/homepage:/app/config
|
||||
environment:
|
||||
- HOMEPAGE_ALLOWED_HOSTS=dashboard.${DOMAIN}
|
||||
networks:
|
||||
- proxy-net
|
||||
- socket-net
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
# HTTPS Router
|
||||
- "traefik.http.routers.homepage.rule=Host(`dashboard.${DOMAIN}`)"
|
||||
- "traefik.http.routers.homepage.entrypoints=websecure"
|
||||
- "traefik.http.routers.homepage.tls=true"
|
||||
- "traefik.http.routers.homepage.tls.certresolver=myresolver"
|
||||
- "traefik.http.routers.homepage.service=homepage-svc"
|
||||
# Public HTTP Redirect
|
||||
- "traefik.http.routers.homepage-red.rule=Host(`dashboard.${DOMAIN}`)"
|
||||
- "traefik.http.routers.homepage-red.entrypoints=web"
|
||||
- "traefik.http.routers.homepage-red.middlewares=https-redirect@docker"
|
||||
# Service Port
|
||||
- "traefik.http.services.homepage-svc.loadbalancer.server.port=3000"
|
||||
```
|
||||
|
||||
#### [MODIFY] `Core/scripts/appctl_engine.py`
|
||||
Update `cmd_sync_homepage()` to target `Core/config/homepage/services.yaml`:
|
||||
```python
|
||||
def cmd_sync_homepage(args):
|
||||
"""Compile Sites/*/app.yaml into Core/config/homepage/services.yaml."""
|
||||
homepage_dir = os.path.join(CORE_DIR, "config", "homepage")
|
||||
for a in args:
|
||||
if a.startswith("--dashboard-dir=") or a.startswith("--homepage-dir="):
|
||||
homepage_dir = a.split("=", 1)[1]
|
||||
|
||||
services_yaml_path = os.path.join(homepage_dir, "services.yaml")
|
||||
...
|
||||
```
|
||||
|
||||
#### [MODIFY] `Core/tests/structural/test_repository_structure.py`
|
||||
Ensure `config/homepage` is validated as part of the core repository structure tests.
|
||||
|
||||
---
|
||||
|
||||
### Component 3: Decommissioning `Homelab/Sites/dashboard`
|
||||
|
||||
1. Once the changes in Core and Courses are verified, tear down any old containers in `Sites/dashboard`.
|
||||
2. Commit and push the initial commit in `Homelab/Sites/courses` (`origin main`).
|
||||
3. Commit and push the Core changes in `Homelab/Core` (`origin main`).
|
||||
4. Archive or remove the local `Sites/dashboard` directory and clean up its Gitea remote repository.
|
||||
|
||||
---
|
||||
|
||||
## Verification Plan
|
||||
|
||||
### Automated Tests
|
||||
1. **Core Structural & Security Invariants**:
|
||||
```bash
|
||||
cd /home/kiskaadee/Homelab/Core
|
||||
uv run --with pytest --with pyyaml pytest tests
|
||||
```
|
||||
2. **Courses Service Unit Tests & Type Check**:
|
||||
```bash
|
||||
cd /home/kiskaadee/Homelab/Sites/courses
|
||||
uv run python -m unittest discover tests
|
||||
uv run pyright
|
||||
```
|
||||
3. **Orchestrator Validation**:
|
||||
```bash
|
||||
appctl sync
|
||||
appctl list
|
||||
appctl config courses
|
||||
appctl config core
|
||||
```
|
||||
|
||||
### Manual Verification
|
||||
1. **Homepage Verification**:
|
||||
- Access `https://dashboard.roadtotech.me`
|
||||
- Verify that Homepage displays system resource widgets and all registered services from `Sites/` (including the new Courses card).
|
||||
- Ensure the previous custom JS injection is removed and Homepage loads cleanly without DOM console warnings.
|
||||
2. **Courses App Verification**:
|
||||
- Access `https://courses.roadtotech.me`
|
||||
- Test adding a course, dragging between WIP / Planning / Archive columns, editing, and deleting.
|
||||
- Verify API status at `https://courses.roadtotech.me/api/courses`.
|
||||
@@ -0,0 +1,167 @@
|
||||
---
|
||||
type: plan
|
||||
status: completed
|
||||
project: homelab
|
||||
tags:
|
||||
- homelab
|
||||
- email
|
||||
- stalwart
|
||||
- lldap
|
||||
---
|
||||
|
||||
# Stalwart Mail Server Implementation Plan (Homelab Core)
|
||||
|
||||
## 1. Executive Architecture
|
||||
|
||||
The email infrastructure will be integrated into the **Homelab Core** stack (`~/Homelab/Core`). It leverages **Stalwart Mail Server** (`stalwartlabs/stalwart:v0.16.22`) as an all-in-one mail server (SMTP, IMAP, JMAP, Sieve, and WebAdmin) integrated with the live **LLDAP** directory for unified user authentication.
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
subgraph Internet ["Public Internet & DNS"]
|
||||
DNS["DNS Records<br/>MX, SPF, DKIM, DMARC"]
|
||||
ExtMTA["External Mail Servers<br/>(Gmail, Proton, Outlook)"]
|
||||
MailClients["Mail Clients<br/>(Thunderbird, Apple Mail, K-9)"]
|
||||
Relay["Outbound Smart Host<br/>(Brevo / AWS SES / Postmark)"]
|
||||
end
|
||||
|
||||
subgraph Host ["Homelab Host (server-remote)"]
|
||||
subgraph Ports ["Host Network Ports"]
|
||||
P25["Port 25 (Inbound SMTP)"]
|
||||
P465["Port 465 (SMTPS)"]
|
||||
P587["Port 587 (Submission)"]
|
||||
P993["Port 993 (IMAPS)"]
|
||||
P443["Port 443 (HTTPS via Traefik)"]
|
||||
end
|
||||
|
||||
subgraph Containers ["Docker Bridge (proxy-net)"]
|
||||
Traefik["Traefik Reverse Proxy<br/>(TLS Termination for HTTPS)"]
|
||||
Stalwart["Stalwart Mail Server<br/>(v0.16.22)"]
|
||||
LLDAP["LLDAP Directory<br/>ldap://lldap:3890"]
|
||||
Homepage["Homepage Dashboard"]
|
||||
end
|
||||
|
||||
subgraph Storage ["Persistent Storage"]
|
||||
StalwartData["./config/stalwart/data<br/>(Mail store & RocksDB)"]
|
||||
StalwartEtc["./config/stalwart/etc<br/>(Config & TLS)"]
|
||||
end
|
||||
end
|
||||
|
||||
ExtMTA -->|"Inbound MX: Port 25"| P25 --> Stalwart
|
||||
MailClients -->|"SMTP Submission: 465/587"| P465 & P587 --> Stalwart
|
||||
MailClients -->|"IMAP: 993"| P993 --> Stalwart
|
||||
MailClients -->|"JMAP / WebAdmin / AutoConfig"| P443 --> Traefik
|
||||
Traefik -->|"HTTP Port 8080"| Stalwart
|
||||
|
||||
Stalwart -->|Auth & User Lookup| LLDAP
|
||||
Stalwart -->|Outbound Send| Relay --> ExtMTA
|
||||
Stalwart --- StalwartData
|
||||
Stalwart --- StalwartEtc
|
||||
Homepage -->|Service Link| Traefik
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Docker Compose Service Definition
|
||||
|
||||
Add the `stalwart` service to [`Core/docker-compose.yml`](file:///home/kiskaadee/Homelab/Core/docker-compose.yml):
|
||||
|
||||
```yaml
|
||||
stalwart:
|
||||
image: stalwartlabs/stalwart:v0.16.22
|
||||
container_name: stalwart
|
||||
restart: always
|
||||
depends_on:
|
||||
- lldap
|
||||
environment:
|
||||
- DOMAIN=${DOMAIN}
|
||||
- STALWART_PUBLIC_URL=https://mail.${DOMAIN}
|
||||
- STALWART_RECOVERY_ADMIN=admin:${LLDAP_LDAP_USER_PASS}
|
||||
ports:
|
||||
- "25:25" # Inbound SMTP (Mail exchange)
|
||||
- "465:465" # SMTPS (Implicit TLS Submission)
|
||||
- "587:587" # SMTP Submission (STARTTLS)
|
||||
- "993:993" # IMAPS (Implicit TLS)
|
||||
- "4190:4190" # ManageSieve (Server-side filtering)
|
||||
volumes:
|
||||
- ./config/stalwart/etc:/etc/stalwart
|
||||
- ./config/stalwart/data:/var/lib/stalwart
|
||||
networks:
|
||||
- proxy-net
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
# WebAdmin & JMAP Router (HTTPS)
|
||||
- "traefik.http.routers.stalwart.rule=Host(`mail.${DOMAIN}`)"
|
||||
- "traefik.http.routers.stalwart.entrypoints=websecure"
|
||||
- "traefik.http.routers.stalwart.tls=true"
|
||||
- "traefik.http.routers.stalwart.tls.certresolver=myresolver"
|
||||
- "traefik.http.routers.stalwart.service=stalwart-svc"
|
||||
# WebAdmin & JMAP (Redirect HTTP -> HTTPS)
|
||||
- "traefik.http.routers.stalwart-red.rule=Host(`mail.${DOMAIN}`)"
|
||||
- "traefik.http.routers.stalwart-red.entrypoints=web"
|
||||
- "traefik.http.routers.stalwart-red.middlewares=https-redirect@docker"
|
||||
# Target Port: Stalwart internal HTTP listener (8080)
|
||||
- "traefik.http.services.stalwart-svc.loadbalancer.server.port=8080"
|
||||
```
|
||||
|
||||
> [!IMPORTANT]
|
||||
> `mail.${DOMAIN}` handles both the Stalwart WebAdmin interface and standard client API endpoints (`/.well-known/jmap`, `/jmap`, autodiscover). Therefore, it should authenticate natively via Stalwart and LLDAP rather than using Traefik's `authelia-auth` forward-auth middleware (which would break API access for mail clients).
|
||||
|
||||
---
|
||||
|
||||
## 3. LLDAP Directory Connector
|
||||
|
||||
Stalwart queries the existing LLDAP container over `proxy-net` (`ldap://lldap:3890`).
|
||||
|
||||
### LLDAP Mapping Configuration
|
||||
- **Server URL:** `ldap://lldap:3890`
|
||||
- **Bind DN:** `uid=admin,ou=people,dc=roadtotech,dc=me`
|
||||
- **Bind Password:** `${LLDAP_LDAP_USER_PASS}`
|
||||
- **Base DN:** `ou=people,dc=roadtotech,dc=me`
|
||||
- **User Filter:** `(&(objectClass=person)(mail=%s))` or `(&(objectClass=person)(uid=%s))`
|
||||
- **Address Mapping:** Primary address is mapped from `mail` (`<user_id>@roadtotech.me`).
|
||||
- **Recovery / Forwarding:** LLDAP `recovery-email` can be used for account recovery notifications.
|
||||
|
||||
Stalwart provisions mailboxes just-in-time when the LLDAP user first logs in or receives an inbound email.
|
||||
|
||||
---
|
||||
|
||||
## 4. Deliverability & Smart Host Relay
|
||||
|
||||
Residential ISPs and dynamic/semi-static residential IP ranges are universally listed on anti-spam blocklists (Spamhaus PBL) and often restrict outbound port 25.
|
||||
|
||||
To guarantee that outgoing emails reach recipient inboxes (Gmail, Yahoo, Outlook):
|
||||
1. **Inbound:** Handled directly by Stalwart on port 25.
|
||||
2. **Outbound:** Routed via an authenticated SMTP relay (Smart Host):
|
||||
- **Brevo (formerly Sendinblue):** Free 300 emails/day, turnkey SMTP credentials.
|
||||
- **Amazon SES:** $0.10 per 10,000 emails, enterprise-grade deliverability.
|
||||
- **SendGrid / Mailgun / Postmark:** Alternative reputable relays.
|
||||
|
||||
---
|
||||
|
||||
## 5. Required DNS Records (`roadtotech.me`)
|
||||
|
||||
| Type | Host / Name | Value | Purpose |
|
||||
|---|---|---|---|
|
||||
| **A / CNAME** | `mail` | Dynamic IP / `roadtotech.me` | Mail server public endpoint |
|
||||
| **MX** | `@` | `10 mail.roadtotech.me.` | Inbound mail routing |
|
||||
| **TXT (SPF)** | `@` | `v=spf1 mx include:<relay-provider-domain> ~all` | Authorizes Stalwart and the outbound relay |
|
||||
| **TXT (DKIM)** | `<selector>._domainkey` | `v=DKIM1; k=rsa; p=<stalwart-public-key>` | Cryptographic signature of outgoing emails |
|
||||
| **TXT (DMARC)** | `_dmarc` | `v=DMARC1; p=quarantine; rua=mailto:admin@roadtotech.me` | Anti-spoofing policy and delivery reporting |
|
||||
|
||||
---
|
||||
|
||||
## 6. Phased Implementation Roadmap
|
||||
|
||||
1. **Phase 1: Compose & Storage Scaffold:**
|
||||
- Create directories `./config/stalwart/etc` and `./config/stalwart/data`.
|
||||
- Update `docker-compose.yml` with the Stalwart service and Traefik routing.
|
||||
- Deploy container and verify initial startup and WebAdmin reachability at `https://mail.roadtotech.me`.
|
||||
2. **Phase 2: LLDAP Directory Binding:**
|
||||
- Connect Stalwart to `ldap://lldap:3890` using the internal LLDAP credentials.
|
||||
- Test user lookup and authentication with existing directory accounts (`kiskaadee@roadtotech.me`, etc.).
|
||||
3. **Phase 3: Outbound Relay & DNS Records:**
|
||||
- Configure outbound smart host credentials.
|
||||
- Export Stalwart DKIM public keys and generate the complete set of DNS records for `roadtotech.me`.
|
||||
4. **Phase 4: Dashboard Integration & Verification:**
|
||||
- Add Stalwart Mail widget/tile to Homepage dashboard (`dashboard.roadtotech.me`).
|
||||
- Run end-to-end inbound and outbound email delivery tests.
|
||||
Reference in new issue
Block a user