veza/veza-docs/docs/infra/networking/index.mdx

165 lines
3.6 KiB
Text
Raw Normal View History

---
id: networking
title: Réseau et Load Balancing
sidebar_label: Réseau
description: Configuration réseau et load balancing avec HAProxy
keywords: [veza, networking, haproxy, load-balancing, dns]
---
# 🌐 Réseau et Load Balancing
Configuration réseau et load balancing pour Veza Platform.
## 🎯 Vue d'Ensemble
- **HAProxy** pour le load balancing
- **Coraza WAF** pour la sécurité
- **DNS** et résolution de noms
- **SSL/TLS** et certificats
## 🏗️ Architecture Réseau
```mermaid
flowchart TB
subgraph "Internet"
USERS[Utilisateurs]
end
subgraph "Edge Layer"
DNS[DNS<br/>Cloudflare]
LB[HAProxy<br/>Load Balancer]
WAF[Coraza<br/>WAF]
end
subgraph "Application Layer"
API[API Services]
CHAT[Chat Services]
STREAM[Stream Services]
end
USERS --> DNS
DNS --> LB
LB --> WAF
WAF --> API
WAF --> CHAT
WAF --> STREAM
```
## 🔧 Configuration HAProxy
```haproxy
global
daemon
log stdout local0
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
defaults
mode http
log global
option httplog
option dontlognull
option log-health-checks
option forwardfor
option httpchk GET /health
timeout connect 5000
timeout client 50000
timeout server 50000
frontend veza_frontend
bind *:80
bind *:443 ssl crt /etc/ssl/certs/veza.pem
redirect scheme https if !{ ssl_fc }
# WAF Rules
http-request deny if { req.hdr(User-Agent) -i "bot" }
# Routing
use_backend api_backend if { path_beg /api/ }
use_backend chat_backend if { path_beg /chat/ }
use_backend stream_backend if { path_beg /stream/ }
default_backend web_backend
backend api_backend
balance roundrobin
server api1 10.0.1.10:8081 check
server api2 10.0.1.11:8081 check
server api3 10.0.1.12:8081 check
backend chat_backend
balance roundrobin
server chat1 10.0.2.10:3001 check
server chat2 10.0.2.11:3001 check
backend stream_backend
balance roundrobin
server stream1 10.0.3.10:3002 check
server stream2 10.0.3.11:3002 check
backend web_backend
balance roundrobin
server web1 10.0.4.10:5176 check
server web2 10.0.4.11:5176 check
```
## 🛡️ Sécurité Réseau
### Coraza WAF
- **Protection** contre les attaques OWASP Top 10
- **Rate limiting** par IP et utilisateur
- **Filtrage** des requêtes malveillantes
- **Logs** détaillés des tentatives d'attaque
### SSL/TLS
- **Certificats** Let's Encrypt automatiques
- **TLS 1.3** et chiffrement fort
- **HSTS** et sécurité renforcée
- **Renouvellement** automatique des certificats
## 📊 Monitoring Réseau
### Métriques HAProxy
- **Connexions** actives et totales
- **Débit** et latence par backend
- **Erreurs** et codes de statut
- **Health checks** des serveurs
### Alertes
- **Serveur** en panne → Slack #ops-alerts
- **Latence** élevée → Slack #performance-alerts
- **Attaques** détectées → Slack #security-alerts
## 🚀 Déploiement
### Docker Compose
```yaml
services:
haproxy:
image: haproxy:2.8
ports:
- "80:80"
- "443:443"
volumes:
- ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg
- ./ssl:/etc/ssl/certs
depends_on:
- api
- chat
- stream
coraza:
image: coraza/coraza:latest
ports:
- "8080:8080"
volumes:
- ./coraza.conf:/etc/coraza/coraza.conf
```
## 📚 Documentation
- [Guide de Sécurité](/docs/infra/security)
- [Guide de Monitoring](/docs/infra/observability)