Project Phoenyx – Part 10: The Master Blueprint (Config Reference)
example.com). Replace them with your own values!
1. Environment Variables (.env)
We do not store secrets directly in the Compose files. We use a central .env file in the root directory (/opt/containers/.env). Docker Compose automatically loads this file and populates the variables (${VARIABLE}) in the other files.
# === PROJECT PHOENYX MAIN CONFIGURATION === # Location: /opt/containers/.env # --- Domain Settings --- DOMAIN_NAME=example.com ACME_EMAIL[email protected] # --- Cloudflare (for DNS Challenge & Traefik) --- CLOUDFLARE_DNS_API_TOKEN=your-very-long-cloudflare-token # --- Crowdsec (Security) --- # Generated with: docker exec -t crowdsec_lapi cscli bouncers add traefik-bouncer CROWDSEC_LAPI_KEY=your-generated-bouncer-key # --- MariaDB (Database) --- MYSQL_ROOT_PASSWORD=super-secure-root-password-please-change # --- Authentik (Identity Provider) --- # Generate with: openssl rand -base64 32 AUTHENTIK_SECRET_KEY=random-string-for-cookies-and-sessions POSTGRES_PASSWORD=secure-db-password-for-authentik # Token from Authentik Admin Interface (Outposts) AUTHENTIK_OUTPOST_TOKEN=token-from-authentik-web-interface
2. The Headquarters (docker-compose.yml)
This file controls everything. Thanks to include, it remains extremely short.
Path: /opt/containers/docker-compose.yml
include: - ./networks/network.yml # Defines infrastructure - ./socket-proxy/socket-proxy-docker-compose.yml # Protects Docker Daemon - ./traefik/traefik-docker-compose.yml # Reverse Proxy - ./crowdsec/crowdsec-docker-compose.yml # IDS / IPS Protection - ./authentik/authentik-docker-compose.yml # SSO & Auth - ./mariadb/mariadb-docker-compose.yml # Database Server
3. The Network (network.yml)
Here we define our security zones with fixed IPs.
Path: /opt/containers/networks/network.yml
networks: # === INTERNAL NETWORKS (No Internet Access!) === authentik-internal: driver: bridge enable_ipv6: true internal: true # Isolated! ipam: config: - subnet: 172.28.0.0/25 - subnet: fd00:1:be:a:7001:0:1::/123 database_internal: internal: true # Database cannot phone home enable_ipv6: true ipam: config: - subnet: 172.28.0.128/25 - subnet: fd00:1:be:a:7001:0:2::/123 socket_proxy: internal: true # Only for Traefik <-> Proxy communication enable_ipv6: true ipam: config: - subnet: 172.28.2.0/25 - subnet: fd00:1:be:a:7001:0:5::/123 # === COMMUNICATION NETWORKS === crowdsec: enable_ipv6: true ipam: config: - subnet: 172.28.1.0/25 - subnet: fd00:1:be:a:7001:0:3::/123 traefik_public: name: traefik_public enable_ipv6: true attachable: true # Allows other containers (WP, Nextcloud) to join ipam: config: - subnet: 172.28.1.128/25 - subnet: fd00:1:be:a:7001:0:4::/123
4. Socket Proxy
Path: /opt/containers/socket-proxy/socket-proxy-docker-compose.yml
services: socket-proxy: image: tecnativa/docker-socket-proxy restart: always volumes: - /var/run/docker.sock:/var/run/docker.sock:ro # Read-Only Mount of Host! environment: CONTAINERS: 1 # Allows Traefik to read NETWORKS: 1 SERVICES: 1 POST: 0 # Forbids write access (Security!) networks: - socket_proxy
5. Traefik (Docker & Static)
This is where the magic happens. Traefik connects everything.
Path: /opt/containers/traefik/traefik-docker-compose.yml
services: traefik: image: traefik:latest restart: always environment: - CLOUDFLARE_DNS_API_TOKEN # From .env - CROWDSEC_LAPI_KEY # From .env networks: - traefik_public - crowdsec - socket_proxy ports: - "80:80" - "443:443" volumes: - ./traefik.yml:/etc/traefik/traefik.yml:ro - ./acme/acme.json:/letsencrypt/acme.json - /var/log/traefik:/var/log/traefik labels: - "traefik.enable=true" # Dashboard Configuration - "traefik.http.routers.traefik.rule=Host(`traefik.example.com`)" - "traefik.http.routers.traefik.entrypoints=websecure" - "traefik.http.routers.traefik.tls.certresolver=letsencrypt" - "traefik.http.routers.traefik.service=api@internal" - "traefik.http.routers.traefik.middlewares=auth-traefik,crowdsec" # Double protection! # Crowdsec Middleware Definition - "traefik.http.middlewares.crowdsec.plugin.crowdsec.crowdsecLapiUrl=http://crowdsec_lapi:8080" - "traefik.http.middlewares.crowdsec.plugin.crowdsec.crowdsecLapiKey=${CROWDSEC_LAPI_KEY}"
The Static Config: /opt/containers/traefik/traefik.yml
entryPoints: web: address: ":80" http: redirections: entryPoint: to: websecure scheme: https websecure: address: ":443" forwardedHeaders: trustedIPs: # Cloudflare IPs (shortened) - "173.245.48.0/20" - "103.21.244.0/22" - "..." providers: docker: endpoint: "tcp://socket-proxy:2375" # Via Proxy! exposedByDefault: false certificatesResolvers: letsencrypt: acme: email: "[email protected]" storage: "/letsencrypt/acme.json" dnsChallenge: provider: cloudflare
6. Crowdsec
Path: /opt/containers/crowdsec/crowdsec-docker-compose.yml
services: crowdsec: image: crowdsecurity/crowdsec:v1.7.3 container_name: crowdsec_lapi restart: always environment: - COLLECTIONS=crowdsecurity/traefik crowdsecurity/http-cve networks: - crowdsec volumes: - ./config:/etc/crowdsec - ./data:/var/lib/crowdsec/data - /var/log/traefik:/var/log/traefik:ro # Reads Traefik Logs
7. Authentik
Path: /opt/containers/authentik/authentik-docker-compose.yml
services: postgresql: image: postgres:16-alpine environment: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} networks: - authentik-internal server: image: ghcr.io/goauthentik/server:2025.10 environment: AUTHENTIK_REDIS__ENABLED: 'false' AUTHENTIK_POSTGRESQL__HOST: postgresql AUTHENTIK_POSTGRESQL__PASSWORD: ${POSTGRES_PASSWORD} AUTHENTIK_SECRET_KEY: ${AUTHENTIK_SECRET_KEY} networks: - traefik_public # For Web Access - authentik-internal # For DB Access labels: - "traefik.enable=true" - "traefik.http.routers.authentik.rule=Host(`auth.example.com`)" - "traefik.http.routers.authentik.entrypoints=websecure" - "traefik.http.routers.authentik.tls.certresolver=letsencrypt" authentik-outpost-traefik: image: ghcr.io/goauthentik/proxy:2025.10 environment: - AUTHENTIK_HOST=https://auth.example.com/ - AUTHENTIK_TOKEN=${AUTHENTIK_OUTPOST_TOKEN} networks: - traefik_public labels: # Forward Auth Middleware Definition - "traefik.http.middlewares.auth-traefik.forwardauth.address=http://authentik-outpost-traefik:9000/outpost.goauthentik.io/auth/traefik" - "traefik.http.middlewares.auth-traefik.forwardauth.trustForwardHeader=true" - "traefik.http.middlewares.auth-traefik.forwardauth.authResponseHeaders=X-Authentik-Username,X-Authentik-Email"
8. MariaDB
Path: /opt/containers/mariadb/mariadb-docker-compose.yml
services: mariadb-global: image: mariadb:11.3 container_name: mariadb-global environment: - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} networks: - database_internal # Isolated! volumes: - mariadb-global-data:/var/lib/mysql