Skip to content

Global Traefik Infrastructure v2.0 - Complete development environment with reverse proxy, databases (MySQL 8.4.6, PostgreSQL 16, Redis), project integration scripts, and comprehensive tooling for cyber-nomad blog and Red Rum Racing AI

Notifications You must be signed in to change notification settings

razor303Jc/global-traefik

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌐 Global Traefik Infrastructure

Advanced reverse proxy setup for managing multiple external projects with automatic SSL, load balancing, and comprehensive development stack

This repository provides a production-ready Traefik v3.0 configuration designed to manage multiple external projects with:

  • Automatic HTTPS with Let's Encrypt SSL certificates
  • Development Stack with PostgreSQL, MySQL, Redis, and Mailhog
  • Security Middleware with rate limiting, CORS, and security headers
  • Project Integration for Cyber-Nomad blog and Red Rum Racing AI

🚀 Quick Start

Development Environment (Recommended)

  1. Setup the complete development stack:

    ./setup-dev.sh
  2. Start all development services:

    ./manage.sh start-dev
  3. Access development services:

Production Environment

  1. Setup production infrastructure:

    ./setup.sh
  2. Configure production settings:

    • Edit traefik.prod.yml - replace your-email@example.com
    • Update admin password in docker-compose.prod.yml
  3. Start production Traefik:

    ./manage.sh start

Integrated Projects

Cyber-Nomad Ghost Blog

./setup-cyber-nomad.sh

Red Rum Racing AI

./setup-red-rum.sh

🏗️ Infrastructure Overview

Core Services (Development)

  • Traefik v3.0: Reverse proxy with automatic service discovery
  • PostgreSQL 16: Primary database with cyber_nomad, red_rum, and test_db databases
  • MySQL 8.4.6: Secondary database with matching databases
  • Redis 7: Caching and session storage
  • Mailhog: Email testing and development

Current Projects

  1. Cyber-Nomad Blog - Ghost 5-alpine blog platform
  2. Red Rum Racing AI - FastAPI horse racing handicapping system

📁 Project Structure

global-traefik/
├── 🔧 Core Configuration
│   ├── docker-compose.dev.yml          # Development stack (Traefik + DBs)
│   ├── docker-compose.prod.yml         # Production Traefik
│   ├── traefik-dev.yml                 # Development static config
│   ├── traefik.prod.yml                # Production static config
│   └── dynamic/middlewares.yml         # Security & CORS middlewares
│
├── 🚀 Project Configurations
│   ├── docker-compose.cyber-nomad-final.yml  # Ghost blog config
│   ├── setup-cyber-nomad.sh            # Blog setup script
│   ├── setup-red-rum.sh                # Racing AI setup script
│   └── test-red-rum.sh                 # Racing AI test suite
│
├── 🛠️ Management Scripts
│   ├── setup-dev.sh                    # Development environment setup
│   ├── setup.sh                        # Production setup
│   └── manage.sh                       # Service management
│
├── 📂 Data & Storage
│   ├── acme/                           # SSL certificates (prod)
│   ├── certs/                          # Self-signed certs (dev)
│   ├── logs/                           # Traefik logs
│   ├── backups/                        # Database backups
│   └── cyber-nomad/                    # Blog content volume
│
└── 📋 Configuration Templates
    ├── .env.dev.example                # Development environment
    └── .env.prod.example               # Production environment

🔧 Database Information

PostgreSQL (Port 5432)

  • Host: localhost (external) / postgres-dev (internal)
  • Credentials: devuser / devpass
  • Databases:
    • cyber_nomad - Ghost blog data
    • red_rum - Racing AI data
    • test_db - Development testing

MySQL 8.4.6 (Port 3306)

  • Host: localhost (external) / mysql-dev (internal)
  • Credentials: devuser / devpass
  • Databases: Same as PostgreSQL
  • Features: Updated from 8.0, fixed authentication plugins

Redis (Port 6379)

  • Host: localhost (external) / redis-dev (internal)
  • Use Cases: Caching, session storage, real-time data

🌐 Project Integration Guide

Adding New External Projects

All external projects connect via the traefik-dev network and use Traefik labels for routing.

Basic Project Template

version: "3.8"
services:
  your-service:
    image: your-app:latest
    container_name: your-app
    restart: unless-stopped
    labels:
      # Enable Traefik
      - "traefik.enable=true"

      # HTTPS router
      - "traefik.http.routers.your-app.rule=Host(\`your-app.localhost\`)"
      - "traefik.http.routers.your-app.entrypoints=https"
      - "traefik.http.routers.your-app.tls=true"
      - "traefik.http.services.your-app.loadbalancer.server.port=8000"

      # HTTP redirect
      - "traefik.http.routers.your-app-insecure.rule=Host(\`your-app.localhost\`)"
      - "traefik.http.routers.your-app-insecure.entrypoints=http"
      - "traefik.http.routers.your-app-insecure.middlewares=redirect-to-https"

      # HTTPS redirect middleware
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
    networks:
      - traefik-dev

networks:
  traefik-dev:
    external: true

Cyber-Nomad Blog Integration

The Ghost blog connects to the global MySQL database:

services:
  cyber-nomad-blog:
    image: ghost:5-alpine
    environment:
      - url=https://cyber-nomad.localhost
      - database__client=mysql
      - database__connection__host=mysql-dev
      - database__connection__user=devuser
      - database__connection__password=devpass
      - database__connection__database=cyber_nomad
    labels:
      - "traefik.http.routers.cyber-nomad.rule=Host(\`cyber-nomad.localhost\`)"
      # ... Traefik configuration
    networks:
      - traefik-dev

Red Rum Racing AI Integration

The FastAPI application connects to PostgreSQL and Redis:

services:
  racing-ai-api:
    image: python:3.11-slim
    environment:
      - DATABASE_URL=postgresql://devuser:devpass@postgres-dev/red_rum
      - REDIS_URL=redis://redis-dev:6379
    labels:
      - "traefik.http.routers.red-rum-api.rule=Host(\`red-rum.localhost\`)"
      # ... Traefik configuration
    networks:
      - traefik-dev

🔐 Security & Configuration

Admin Password Configuration

Generate a new password hash:

htpasswd -nb admin yourpassword

Update the traefik.http.middlewares.auth.basicauth.users label in production config.

SSL Certificates

  • Development: Self-signed certificates for *.localhost domains
  • Production: Let's Encrypt automatic SSL with email notifications
  • Staging: Uncomment staging configuration for testing

Available Middlewares

  • security-headers: HSTS, XSS protection, content-type sniffing protection
  • rate-limit: Rate limiting (10 req/sec, burst 50)
  • cors: Cross-origin resource sharing for APIs
  • admin-whitelist: IP whitelist for admin areas
  • auth: Basic authentication for protected areas

🔍 Monitoring & Testing

Service Health Monitoring

  • Traefik Dashboard: https://traefik.localhost

    • View all active routers and services
    • Monitor SSL certificate status
    • Check middleware configurations
  • Application Logs:

    # Traefik logs
    docker logs traefik-dev -f
    
    # Database logs
    docker logs postgres-dev -f
    docker logs mysql-dev -f
    
    # Project logs
    docker logs cyber-nomad-blog -f
    docker logs racing-ai-simple -f

Comprehensive Testing

Test All Services

# Run Red Rum test suite
./test-red-rum.sh

# Manual service testing
curl -k https://traefik.localhost      # Dashboard
curl -k https://whoami.localhost       # Test service
curl -k https://mail.localhost         # Mailhog
curl -k https://cyber-nomad.localhost  # Ghost blog
curl -k https://red-rum.localhost      # Racing AI API

Database Connectivity

# PostgreSQL connection
docker exec -it postgres-dev psql -U devuser -d red_rum

# MySQL connection
docker exec -it mysql-dev mysql -u devuser -pdevpass cyber_nomad

# Redis connection
docker exec -it redis-dev redis-cli ping

Performance Monitoring

  • Access Logs: Available in ./logs/ directory with detailed request information
  • Health Checks: Built-in service health monitoring with automatic failover
  • SSL Monitoring: Automatic certificate renewal with email notifications

�️ Management Commands

Service Management

# Start development environment
./manage.sh start-dev

# Stop all services
./manage.sh stop-dev

# Restart specific service
docker restart traefik-dev
docker restart postgres-dev
docker restart mysql-dev

# View service status
docker ps | grep -E "(traefik|postgres|mysql|redis|cyber|racing)"

Database Management

# Create database backups
docker exec postgres-dev pg_dump -U devuser red_rum > backups/red_rum_$(date +%Y%m%d).sql
docker exec mysql-dev mysqldump -u devuser -pdevpass cyber_nomad > backups/cyber_nomad_$(date +%Y%m%d).sql

# Restore database backups
docker exec -i postgres-dev psql -U devuser red_rum < backups/red_rum_backup.sql
docker exec -i mysql-dev mysql -u devuser -pdevpass cyber_nomad < backups/cyber_nomad_backup.sql

Network Management

# Inspect traefik network
docker network inspect traefik-dev

# List connected containers
docker network inspect traefik-dev --format='{{range .Containers}}{{.Name}}: {{.IPv4Address}}{{"\n"}}{{end}}'

# Recreate network if needed
docker network rm traefik-dev
docker network create traefik-dev

� Troubleshooting

Common Issues & Solutions

1. Service Not Accessible

# Check if service is running
docker ps | grep service-name

# Verify Traefik labels
docker inspect service-name | grep -A 20 Labels

# Check Traefik routing
curl -k http://localhost:8080/api/http/routers | jq

2. SSL Certificate Issues

# Check certificate status
curl -k https://traefik.localhost/api/http/routers | jq '.[] | select(.name | contains("service-name"))'

# Force certificate renewal (production)
docker exec traefik-prod rm -rf /etc/traefik/acme/acme.json
docker restart traefik-prod

3. Database Connection Problems

# Test database connectivity
docker exec postgres-dev pg_isready -U devuser
docker exec mysql-dev mysqladmin -u devuser -pdevpass ping

# Check database logs
docker logs postgres-dev --tail 50
docker logs mysql-dev --tail 50

4. Container Network Issues

# Verify network membership
docker network inspect traefik-dev | grep -A 5 service-name

# Reconnect to network
docker network disconnect traefik-dev service-name
docker network connect traefik-dev service-name

Recovery Procedures

Complete Environment Reset

# Stop all services
./manage.sh stop-dev

# Remove all containers (preserves data volumes)
docker container prune -f

# Restart environment
./setup-dev.sh
./manage.sh start-dev

Data Volume Recovery

# List volumes
docker volume ls | grep -E "(cyber|red_rum|postgres|mysql)"

# Backup volumes
docker run --rm -v cyber_nomad_content:/data -v $(pwd)/backups:/backup alpine tar czf /backup/cyber_nomad_content_$(date +%Y%m%d).tar.gz -C /data .

# Restore volumes
docker run --rm -v cyber_nomad_content:/data -v $(pwd)/backups:/backup alpine tar xzf /backup/cyber_nomad_content_backup.tar.gz -C /data

� Current Status

Infrastructure Health

  • Traefik v3.0 - Running and healthy
  • PostgreSQL 16 - Upgraded and optimized
  • MySQL 8.4.6 - Recently upgraded from 8.0
  • Redis 7 - Caching and session storage
  • Mailhog - Email development testing

Active Projects

  • 🚧 Cyber-Nomad Blog - Ghost 5-alpine, MySQL integration
  • 🚧 Red Rum Racing AI - FastAPI, PostgreSQL + Redis integration

Next Steps

  1. Complete project deployments with respective Copilot agents
  2. Set up production SSL certificates
  3. Configure domain routing for production
  4. Implement monitoring and alerting

�📚 Additional Resources

🤝 Contributing

This infrastructure supports rapid development and deployment of new projects. To add a new project:

  1. Create project-specific docker-compose configuration
  2. Add Traefik labels for routing
  3. Connect to traefik-dev network
  4. Use existing databases or add new ones as needed
  5. Create setup script for automated deployment

📄 License

This project is open source and available under the MIT License.


Last Updated: July 30, 2025
Version: 2.0.0 - Comprehensive infrastructure with integrated projects
Maintainer: Global Traefik Infrastructure Team

About

Global Traefik Infrastructure v2.0 - Complete development environment with reverse proxy, databases (MySQL 8.4.6, PostgreSQL 16, Redis), project integration scripts, and comprehensive tooling for cyber-nomad blog and Red Rum Racing AI

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages