# 🎯 Configuration DNS OVH - Panel Admin Web Sentinel

## ⏰ À FAIRE MAINTENANT

### 1. Ajouter les enregistrements DNS dans OVH

Connecte-toi sur ton dashboard OVH et ajoute ces 2 enregistrements DNS :

| Type | Sous-domaine | Cible (IP) | TTL |
|------|--------------|------------|-----|
| **A** | `admin.web-sentinel.taaazzz-prog.fr` | **IP de ton serveur OVH** | 3600 |
| **A** | `admin-api.web-sentinel.taaazzz-prog.fr` | **IP de ton serveur OVH** | 3600 |

📌 **Note** : Utilise la même IP que celle de `web-sentinel.taaazzz-prog.fr`

### 2. Propagation DNS

⏳ **Délai de propagation** : 1 à 24 heures (généralement 1-2h)

Pour vérifier la propagation :
```bash
nslookup admin.web-sentinel.taaazzz-prog.fr
nslookup admin-api.web-sentinel.taaazzz-prog.fr
```

---

## ✅ Configuration Traefik (DÉJÀ FAITE)

### État actuel
- ✅ Traefik configuré avec Let's Encrypt
- ✅ Certresolver : `letsencrypt`
- ✅ Email : bruno@taaazzz.be
- ✅ Labels Traefik ajoutés aux conteneurs admin
- ✅ Réseau correct : `faildaily_faildaily-ssl-network`

### Routes détectées par Traefik
```yaml
admin-frontend@docker:
  Rule: Host(`admin.web-sentinel.taaazzz-prog.fr`)
  EntryPoint: websecure (HTTPS)
  TLS: letsencrypt
  Port: 80

admin-backend@docker:
  Rule: Host(`admin-api.web-sentinel.taaazzz-prog.fr`)
  EntryPoint: websecure (HTTPS)
  TLS: letsencrypt
  Port: 8000
```

---

## 🔐 Certificats SSL Let's Encrypt

### ⚠️ Rate Limit actuel (TEMPORAIRE)
Traefik a tenté de générer les certificats SSL mais a atteint la limite Let's Encrypt :
- **5 échecs d'autorisation** en 1 heure
- **Retry disponible après** : 07/11/2025 à **10:39:44 UTC** (11h39 heure FR)

### 🔄 Génération automatique des certificats
Une fois le DNS configuré et propagé, Traefik générera **automatiquement** les certificats SSL :
1. ✅ HTTP Challenge sur le port 80
2. ✅ Redirection automatique HTTP → HTTPS
3. ✅ Renouvellement automatique avant expiration

**Aucune action manuelle requise** pour les certificats !

---

## 📝 Changements déployés

### 1. docker-compose.admin.yml
```yaml
networks:
  faildaily-ssl-network:
    external: true
    name: faildaily_faildaily-ssl-network
```

Réseau modifié de `faildaily-network` → `faildaily_faildaily-ssl-network` pour correspondre à la configuration Traefik.

### 2. web/account.html
```javascript
// Avant
onclick="window.open('http://localhost:5173', '_blank')"

// Après
onclick="window.open('https://admin.web-sentinel.taaazzz-prog.fr', '_blank')"
```

Le bouton "🛠️ Panel Admin" pointe maintenant vers l'URL de production.

---

## 🧪 Tests à effectuer (APRÈS propagation DNS)

### 1. Vérifier les routes Traefik (maintenant)
```bash
ssh taaazzz@web-sentinel.taaazzz-prog.fr
docker logs faildaily-traefik-ssl 2>&1 | grep -i admin | tail -n 20
```

### 2. Tester l'accès HTTPS (après DNS)
```bash
# Backend API
curl https://admin-api.web-sentinel.taaazzz-prog.fr/api/health

# Frontend (dans un navigateur)
https://admin.web-sentinel.taaazzz-prog.fr
```

### 3. Tester depuis le site Web Sentinel
1. Aller sur https://web-sentinel.taaazzz-prog.fr/account.html
2. Se connecter avec un compte **SYSOP**
3. Cliquer sur **"🛠️ Panel Admin"**
4. Vérifier que le panel s'ouvre sur `https://admin.web-sentinel.taaazzz-prog.fr`

---

## 🔍 Dépannage

### Problème : DNS ne résout pas
```bash
# Vérifier la propagation DNS
dig admin.web-sentinel.taaazzz-prog.fr +short
dig admin-api.web-sentinel.taaazzz-prog.fr +short
```
**Solution** : Attendre la propagation (1-24h)

### Problème : ERR_SSL_PROTOCOL_ERROR
**Cause** : Certificats SSL pas encore générés par Let's Encrypt (rate limit ou DNS non propagé)

**Solution** :
1. Attendre 11h39 (fin du rate limit)
2. Vérifier que le DNS est propagé
3. Les certificats seront générés automatiquement

### Problème : 404 Not Found
**Cause** : Traefik ne route pas correctement

**Solution** :
```bash
ssh taaazzz@web-sentinel.taaazzz-prog.fr
docker restart web-sentinel-admin-frontend web-sentinel-admin-backend
docker logs faildaily-traefik-ssl --tail 50
```

### Problème : CORS Error dans la console
**Cause** : Configuration CORS incorrecte

**Solution** : Vérifier `.env.admin` sur le serveur :
```bash
cat ~/web-sentinel/deployment/.env.admin | grep ALLOWED_ORIGINS
```
Doit contenir : `ALLOWED_ORIGINS=https://admin.web-sentinel.taaazzz-prog.fr`

---

## 📊 État des conteneurs

```bash
# Vérifier que tout tourne
docker ps | grep admin

# Devrait afficher :
# web-sentinel-admin-backend    (Up)
# web-sentinel-admin-frontend   (Up)

# Logs backend
docker logs -f web-sentinel-admin-backend

# Logs frontend
docker logs -f web-sentinel-admin-frontend
```

---

## 🎉 Une fois tout fonctionnel

### Accès au panel admin
- **URL publique** : https://admin.web-sentinel.taaazzz-prog.fr
- **API backend** : https://admin-api.web-sentinel.taaazzz-prog.fr
- **Bouton depuis le site** : Accessible pour les comptes SYSOP uniquement

### Prochaines étapes
- ✅ DNS configuré
- ✅ Certificats SSL générés automatiquement
- ✅ Bouton fonctionnel sur account.html
- ✅ Panel admin accessible en production
- 📝 TODO : Surveiller les logs Traefik pour les premiers accès

---

## 📞 Commandes utiles

```bash
# SSH vers le serveur
ssh taaazzz@web-sentinel.taaazzz-prog.fr

# Redémarrer le panel admin
cd ~/web-sentinel
docker-compose -f deployment/docker-compose.admin.yml restart

# Voir les logs Traefik en temps réel
docker logs -f faildaily-traefik-ssl | grep admin

# Vérifier les certificats SSL
docker exec faildaily-traefik-ssl cat /letsencrypt/acme.json | grep admin

# Tester l'API en local (sur le serveur)
curl http://localhost:8000/api/health
```

---

## 🔒 Sécurité

### ✅ Protections actives
- HTTPS obligatoire (Let's Encrypt)
- Reverse proxy Traefik (pas d'accès direct aux ports)
- Base de données non exposée publiquement
- JWT secret robuste (64 caractères)
- Accès au bouton limité aux comptes SYSOP

### 📌 Rappel
Le panel admin est maintenant **100% en production** et accessible via HTTPS avec certificats SSL automatiques !

---

**Dernière mise à jour** : 7 novembre 2025, 11h41
