📍 المقالة الرئيسية: CrowdSec 2026.
لـ ESN يدير 8 VPS عملاء، أو شركة مع خوادم production + staging + dev، معمارية LAPI مركزي تُمَركِز القرارات: IP محظور على VPS A محظور على الكل.
المتطلبات
5+ VPS Linux. VPN خاص بين VPS (Tailscale). CrowdSec مثبَّت على كل واحد. المستوى: متقدم. الوقت: 1-2 ساعة.
الخطوة 1 — المعمارية
VPS LAPI مركزي: يستضيف LAPI + قاعدة SQLite أو Postgres مُمَرْكَزة. VPS agents: يحللون سجلاتهم، يرسلون تنبيهات إلى LAPI المركزي. Bouncers: على كل VPS، يقرؤون قرارات LAPI المركزي عبر API.
الخطوة 2 — تحضير LAPI المركزي
# /etc/crowdsec/config.yaml على VPS dédié
api:
server:
listen_uri: 0.0.0.0:8080
db_config:
type: sqlite
db_path: /var/lib/crowdsec/data/crowdsec.db
systemctl restart crowdsec
الخطوة 3 — تأمين الوصول إلى LAPI
LAPI يجب ألا يُكشَف علنياً. خيارات: Tailscale (كل agents على tailnet)، WireGuard، Cloudflare Tunnel. التوصية: Tailscale.
الخطوة 4 — تسجيل كل agent في LAPI المركزي
# على كل VPS agent: عطل LAPI المحلي
nano /etc/crowdsec/config.yaml
# تحت api:server: : enabled: false
# Credentials لـ LAPI المركزي
cat > /etc/crowdsec/local_api_credentials.yaml << EOF
url: http://100.64.0.5:8080
login: agent-vps-X
password: GENERATED-VIA-LAPI-CENTRAL
EOF
الخطوة 5 — على LAPI المركزي، أنشئ machine لكل agent
cscli machines add agent-vps-1 --auto
cscli machines add agent-vps-2 --auto
cscli machines add agent-vps-3 --auto
الخطوة 6 — تسجيل bouncers في LAPI المركزي
# على LAPI المركزي
cscli bouncers add bouncer-vps-1 --auto
# على VPS agent
nano /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml
api_url: http://100.64.0.5:8080
api_key: VOTRE_CLE
الخطوة 7 — التحقق من الاتصال
# على LAPI المركزي
cscli machines list
# يجب أن يسرد كل agents مع validated=true
cscli bouncers list
الخطوة 8 — اختبار مشاركة القرارات
# على VPS-1، حاكي هجوماً
ssh badpass@VPS-1
# على LAPI المركزي
cscli alerts list
cscli decisions list --type ban
# على VPS-2 (agent آخر)
cscli decisions list
# يجب أن يرى ban أيضاً
الخطوة 9 — Console موحد
cscli console enroll -e context VOTRE_TOKEN_CONSOLE
الخطوة 10 — Backup مُمَرْكَز
احفظ بانتظام قاعدة SQLite أو Postgres لـ LAPI المركزي.
الأخطاء الشائعة
| الخطأ | الحل |
|---|---|
| Agent لا يصل LAPI | tailscale ping |
| Machine غير مصادقة | cscli machines validate |
| SQLite مشبع | الانتقال إلى Postgres |
التكيف مع السياق
VPN بين datacenters: Hetzner + OVH + Africa Data Centres. التكلفة: 1 LAPI مركزي + 8 agents = بدون تكلفة إضافية. Audit مُمَرْكَز للـ ESN.
دروس الإخوة
الأسئلة المتكررة
حد agents لكل LAPI؟ SQLite: 20 agents. Postgres: 500+.
Failover LAPI؟ 2 LAPIs مع replication Postgres.