|
| 1 | +# Ecency Managed Hosting Platform |
| 2 | + |
| 3 | +Multi-tenant hosting infrastructure for Ecency self-hosted blogs. |
| 4 | + |
| 5 | +## Architecture Overview |
| 6 | + |
| 7 | +``` |
| 8 | + ┌─────────────────────────────────────┐ |
| 9 | + │ DNS (Cloudflare) │ |
| 10 | + │ *.blogs.ecency.com → Load Balancer │ |
| 11 | + │ Custom domains → CNAME validation │ |
| 12 | + └──────────────────┬──────────────────┘ |
| 13 | + │ |
| 14 | + ┌──────────────────▼──────────────────┐ |
| 15 | + │ Load Balancer (Traefik) │ |
| 16 | + │ - SSL termination (Let's Encrypt) │ |
| 17 | + │ - Dynamic routing by hostname │ |
| 18 | + │ - Rate limiting │ |
| 19 | + └──────────────────┬──────────────────┘ |
| 20 | + │ |
| 21 | + ┌───────────────────────────────────────┼───────────────────────────────────────┐ |
| 22 | + │ │ │ |
| 23 | + ┌─────────▼─────────┐ ┌───────────▼───────────┐ ┌────────────▼────────────┐ |
| 24 | + │ Blog Instance │ │ Blog Instance │ │ Hosting API │ |
| 25 | + │ (nginx + SPA) │ │ (nginx + SPA) │ │ (Node.js/Deno) │ |
| 26 | + │ │ │ │ │ │ |
| 27 | + │ alice.blogs.ec... │ │ bob.blogs.ecency... │ │ api.ecency.com/hosting │ |
| 28 | + │ config: alice.json│ │ config: bob.json │ │ │ |
| 29 | + └───────────────────┘ └───────────────────────┘ └────────────┬────────────┘ |
| 30 | + │ |
| 31 | + ┌──────────────────┼──────────────────┐ |
| 32 | + │ │ │ |
| 33 | + ┌────────▼────────┐ ┌───────▼───────┐ ┌────────▼────────┐ |
| 34 | + │ Config DB │ │ HBD Payment │ │ Domain Verify │ |
| 35 | + │ (PostgreSQL) │ │ Listener │ │ Service │ |
| 36 | + │ │ │ │ │ │ |
| 37 | + │ - Tenant configs│ │ - Watch txs │ │ - CNAME check │ |
| 38 | + │ - Subscriptions │ │ - Auto-renew │ │ - SSL provision │ |
| 39 | + │ - Custom domains│ │ - Receipts │ │ │ |
| 40 | + └─────────────────┘ └───────────────┘ └─────────────────┘ |
| 41 | +``` |
| 42 | + |
| 43 | +## Components |
| 44 | + |
| 45 | +### 1. Traefik (Edge Router) |
| 46 | +- Handles all incoming traffic |
| 47 | +- Dynamic routing based on hostname |
| 48 | +- Automatic SSL via Let's Encrypt |
| 49 | +- Wildcard cert for `*.blogs.ecency.com` |
| 50 | + |
| 51 | +### 2. Blog Instances |
| 52 | +- Shared static SPA assets |
| 53 | +- Per-tenant config.json |
| 54 | +- Served via nginx |
| 55 | + |
| 56 | +### 3. Hosting API |
| 57 | +- Tenant management (CRUD) |
| 58 | +- Subscription handling |
| 59 | +- Config generation |
| 60 | +- Domain verification |
| 61 | + |
| 62 | +### 4. HBD Payment Listener |
| 63 | +- Monitors Hive blockchain for payments |
| 64 | +- Activates/renews subscriptions |
| 65 | +- Sends notifications |
| 66 | + |
| 67 | +## Deployment Models |
| 68 | + |
| 69 | +### Model A: Shared Container (Recommended for Scale) |
| 70 | +All tenants share a single nginx container with dynamic config routing. |
| 71 | + |
| 72 | +``` |
| 73 | +┌─────────────────────────────────────┐ |
| 74 | +│ Nginx Container │ |
| 75 | +│ /usr/share/nginx/html/ │ |
| 76 | +│ ├── index.html (shared SPA) │ |
| 77 | +│ ├── static/ (shared assets) │ |
| 78 | +│ └── configs/ │ |
| 79 | +│ ├── alice.json │ |
| 80 | +│ ├── bob.json │ |
| 81 | +│ └── carol.json │ |
| 82 | +│ │ |
| 83 | +│ Config routing via $host header │ |
| 84 | +└─────────────────────────────────────┘ |
| 85 | +``` |
| 86 | + |
| 87 | +### Model B: Container Per Tenant (Isolation) |
| 88 | +Each tenant gets their own container. Higher resource usage but better isolation. |
| 89 | + |
| 90 | +``` |
| 91 | +┌─────────────┐ ┌─────────────┐ ┌─────────────┐ |
| 92 | +│ Alice │ │ Bob │ │ Carol │ |
| 93 | +│ Container │ │ Container │ │ Container │ |
| 94 | +└─────────────┘ └─────────────┘ └─────────────┘ |
| 95 | +``` |
| 96 | + |
| 97 | +## Files |
| 98 | + |
| 99 | +- `docker-compose.yml` - Full hosting stack |
| 100 | +- `traefik/` - Traefik configuration |
| 101 | +- `nginx/` - Multi-tenant nginx config |
| 102 | +- `api/` - Hosting management API |
| 103 | +- `scripts/` - Utility scripts |
| 104 | + |
| 105 | +## Quick Start |
| 106 | + |
| 107 | +```bash |
| 108 | +# Start the hosting platform |
| 109 | +docker-compose up -d |
| 110 | + |
| 111 | +# Add a new tenant |
| 112 | +./scripts/add-tenant.sh alice |
| 113 | + |
| 114 | +# Check tenant status |
| 115 | +./scripts/tenant-status.sh alice |
| 116 | +``` |
0 commit comments