Infrastructure Services#
The three sacred infrastructure services that form the foundation of the MCP OAuth Gateway, following the divine architectural separation.
The Holy Trinity of Infrastructure#
Service Responsibilities#
Traefik - The Divine Router#
Layer 1 Responsibilities:
π¦ Routes all incoming HTTPS traffic
π Provides SSL/TLS termination via Letβs Encrypt
π‘οΈ Enforces authentication via ForwardAuth
βοΈ Load balances across service instances
π Checks service health
Divine Truth: Traefik knows routing, nothing else!
Auth Service - The OAuth Oracle#
Layer 2 Responsibilities:
π Implements OAuth 2.1 specification
π Dynamic client registration (RFC 7591)
π« Issues and validates JWT tokens
π€ Integrates with GitHub for user auth
ποΈ Manages all OAuth state in Redis
Divine Truth: Auth knows OAuth, nothing else!
Redis - The Sacred Storage#
Storage Responsibilities:
πΎ Stores all OAuth client registrations
ποΈ Maintains token lifecycle data
π Handles session state
β±οΈ Manages TTL for temporary data
π Provides atomic operations
Divine Truth: Redis stores state, nothing else!
Architectural Principles#
Separation of Concerns#
Each infrastructure service has a single, well-defined responsibility:
Traefik:
knows:
- routing rules
- SSL certificates
- service discovery
does_not_know:
- OAuth logic
- token validation
- user authentication
Auth:
knows:
- OAuth protocols
- token generation
- user validation
does_not_know:
- routing decisions
- SSL management
- MCP protocols
Redis:
knows:
- key-value storage
- TTL management
- data persistence
does_not_know:
- OAuth logic
- routing rules
- authentication
Communication Flow#
1. Client Request β Traefik
2. Traefik β Auth (/verify)
3. Auth β Redis (token lookup)
4. Redis β Auth (token data)
5. Auth β Traefik (valid/invalid)
6. Traefik β MCP Service (if valid)
Configuration Hierarchy#
Environment Variables#
Common infrastructure variables:
# Base configuration
BASE_DOMAIN=example.com
ACME_EMAIL=admin@example.com
# Auth configuration
GITHUB_CLIENT_ID=xxx
GITHUB_CLIENT_SECRET=xxx
GATEWAY_JWT_SECRET=xxx
# Redis configuration
REDIS_PASSWORD=xxx
# Access control
ALLOWED_GITHUB_USERS=user1,user2
Docker Networks#
All infrastructure services share the public
network:
networks:
public:
external: true
Volume Management#
Persistent data volumes:
volumes:
traefik-certificates: # SSL certificates
redis-data: # OAuth data
auth-keys: # RSA signing keys
Health Checks#
Service Health Endpoints#
Service |
Health Check |
Expected Response |
---|---|---|
Traefik |
|
Exit 0 |
Auth |
|
|
Redis |
|
|
Health Check Commands#
# Check all infrastructure
just check-health
# Individual service health
docker exec traefik traefik healthcheck
curl http://auth:8000/health
docker exec redis redis-cli ping
Security Model#
Defense in Depth#
Traefik Layer
HTTPS only (redirect HTTP)
Valid SSL certificates
Security headers
Auth Layer
JWT token validation
User allowlist
Client authentication
Redis Layer
Password protection
Network isolation
No external exposure
Zero Trust Principles#
Every request authenticated
No implicit trust between services
Minimal privilege access
Audit trail via logs
Disaster Recovery#
Backup Strategy#
# Backup all infrastructure data
just oauth-backup # OAuth registrations
docker exec redis BGSAVE # Redis snapshot
Recovery Process#
Traefik: Certificates regenerated automatically
Auth: Restore from OAuth backup
Redis: Restore from snapshot
Scaling Considerations#
Horizontal Scaling#
Service |
Scalable |
Considerations |
---|---|---|
Traefik |
β Yes |
Use multiple instances with shared config |
Auth |
β Yes |
Stateless with Redis backend |
Redis |
β οΈ Limited |
Use Redis Cluster for HA |
Performance Tuning#
# Traefik
- High connection limits
- Optimized buffers
- Health check intervals
# Auth
- Connection pooling
- JWT caching
- Async operations
# Redis
- Memory limits
- Persistence settings
- Connection limits
Troubleshooting Guide#
Common Issues#
SSL Certificate Problems
Check Traefik logs
Verify DNS resolution
Check ACME email
Authentication Failures
Verify token format
Check Auth logs
Test /verify endpoint
Redis Connection Issues
Check password
Verify network
Monitor memory
Debug Commands#
# Traefik routing
just logs traefik | grep error
# Auth service
just logs auth | grep -E "error|warn"
# Redis operations
just exec redis redis-cli monitor
Best Practices#
Regular Backups: Automate OAuth and Redis backups
Check Health: Verify service health regularly
Rotate Secrets: Periodically update passwords and keys
Update Regularly: Keep services at latest versions
Capacity Planning: Track resource usage trends
Documentation: Keep runbooks updated