From b4344e9d6649262acca4d81ac28cadadfa6f98b5 Mon Sep 17 00:00:00 2001 From: EduBox Dev Date: Tue, 23 Jun 2026 09:53:02 +0000 Subject: [PATCH] =?UTF-8?q?docs(vpn):=20mise=20=C3=A0=20jour=20du=20suivi?= =?UTF-8?q?=20=E2=80=93=20flux=20web=20OK=20et=20=C3=A9tude=20wildcard=20I?= =?UTF-8?q?nfomaniak?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUIVI_VPN_ONDEMAND.md | 94 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 3 deletions(-) diff --git a/SUIVI_VPN_ONDEMAND.md b/SUIVI_VPN_ONDEMAND.md index f3435b6..dbbe1c2 100644 --- a/SUIVI_VPN_ONDEMAND.md +++ b/SUIVI_VPN_ONDEMAND.md @@ -130,17 +130,105 @@ docker exec studioe5-caddy curl -sS -I -H "Host: test-wp-001.studioe5.edudeploy. curl -sS -I -L https://test-wp-001.studioe5.edudeploy.com/ ``` +## 🌐 Flux complet testĂ© via l’API web + +Test rĂ©alisĂ© le 2026-06-23 en utilisant le compte superadmin : + +1. **Authentification NextAuth** sur `/api/auth/callback/credentials`. +2. **CrĂ©ation d’instance** via `POST /api/instances` : + ```json + { + "nodeId": "vps-8fc665eb", + "templateId": "wordpress-wordpress-latest", + "port": 8002 + } + ``` + → Instance créée : `cmqqgrur20001lw67t2bdgzkg`. +3. Le serveur a automatiquement envoyĂ© l’action `start` au node via WebSocket. +4. L’agent a dĂ©marrĂ© le VPN (si besoin), Ă©crit le compose et a lancĂ© les conteneurs WordPress. +5. Caddy a obtenu un certificat Let’s Encrypt pour `cmqqgrur20001lw67t2bdgzkg.studioe5.edudeploy.com`. +6. **Validation HTTPS** : + ```bash + curl -sS -I -L https://cmqqgrur20001lw67t2bdgzkg.studioe5.edudeploy.com/ + # => HTTP/2 302 -> HTTP/2 200 (WordPress install.php) + ``` + +Le flux `UI → API → WebSocket → agent → Docker → VPN → Caddy → HTTPS public` est fonctionnel. + ## 📋 Prochaines Ă©tapes Ă  faire - [x] ~~Attendre la fin du rate limit Let’s Encrypt~~ (levĂ© le 2026-06-23). - [x] ~~Relancer un test HTTPS sur `https://test-wp-001.studioe5.edudeploy.com/`~~ → **OK** (HTTP/2 200). -- [ ] **Nettoyer l’instance test et l’agent test**, puis **committer les modifications** (il reste beaucoup de fichiers modifiĂ©s/non suivis ; voir `git status`). -- [ ] **Si le wildcard DNS est stable**, envisager d’obtenir un certificat wildcard unique pour `*.studioe5.edudeploy.com` (Ă©vite d’émettre un certificat par instance et donc de retomber dans les rate limits). À Ă©tudier cĂŽtĂ© Caddy (`tls { on_demand }` vs certificat wildcard gĂ©rĂ© manuellement). -- [ ] **Tester le flux complet depuis l’interface web** (activation d’un Ă©lĂšve, crĂ©ation d’instance via l’UI). +- [x] ~~CrĂ©er une branche dĂ©diĂ©e et commiter les modifications VPN on-demand~~ → branche `feat/studioe5-vpn-ondemand`, commit `124543d`. Push vers Gitea Ă  faire dĂšs que le remote sera accessible (actuellement `localhost:3001` et `gitea.alfrednobel.edudeploy.com` injoignables). +- [x] ~~Tester le flux complet depuis l’interface web~~ → **OK** via l’API authentifiĂ©e (`POST /api/instances`), instance `cmqqgrur20001lw67t2bdgzkg` accessible en HTTPS public. +- [ ] **Obtenir un certificat wildcard** pour `*.studioe5.edudeploy.com` (voir Ă©tude ci-dessous). +- [ ] **Nettoyer les instances/agent de test** une fois le wildcard en place et le push effectuĂ©. - [ ] **Packager les binaires Tailscale pour Windows** dans `agent/tailscale-bin/windows/`. - [ ] **Nettoyer les anciens nodes/volumes Headscale** créés pendant les tests. - [ ] **Documenter la procĂ©dure de mise en production** pour le client A (config agent, clĂ©s Headscale, ports, etc.). +## 🔒 Étude certificat wildcard `*.studioe5.edudeploy.com` + +### Pourquoi passer en wildcard ? + +Avec `tls { on_demand }`, Caddy Ă©met **un certificat Let’s Encrypt par sous-domaine d’instance**. Cela expose au rate limit de 50 certificats par domaine principal (`edudeploy.com`) sur 7 jours. Un certificat wildcard unique (`*.studioe5.edudeploy.com`) couvre tous les sous-domaines d’instances et Ă©vite ce problĂšme. + +### Contrainte technique + +Un certificat wildcard nĂ©cessite le **challenge DNS-01** (le challenge HTTP-01 ne permet pas de valider `*.domain.tld`). Caddy doit donc pouvoir crĂ©er un enregistrement TXT automatiquement chez le registrar DNS. + +### Infomaniak (registrar actuel) + +Le DNS de `edudeploy.com` est chez **Infomaniak** : +```bash +dig NS edudeploy.com +short +# nsany1.infomaniak.com. +# nsany2.infomaniak.com. +``` + +Il existe un module Caddy DNS pour Infomaniak : +- Repository : `github.com/caddy-dns/infomaniak` +- NĂ©cessite un **token API Infomaniak** avec droits DNS. + +### ImplĂ©mentation Ă  envisager + +1. **GĂ©nĂ©rer un token API Infomaniak** (compte client A ou compte dĂ©diĂ© avec accĂšs au domaine). +2. **Builder une image Caddy custom** avec le module : + ```dockerfile + FROM caddy:2-builder AS builder + RUN xcaddy build --with github.com/caddy-dns/infomaniak + + FROM caddy:2-alpine + COPY --from=builder /usr/bin/caddy /usr/bin/caddy + ``` +3. **Modifier le `Caddyfile`** pour gĂ©rer le wildcard : + ```caddy + *.studioe5.edudeploy.com { + tls { + dns infomaniak {env.INFOMANIAK_API_TOKEN} + } + reverse_proxy resolver:2020 { + header_up Host {host} + } + } + ``` +4. **Ajouter le token dans `.env`** et le passer au conteneur Caddy. +5. Supprimer ou ajuster le bloc `:443` actuel qui utilise `on_demand` pour les instances. + +### Alternative sans module DNS + +Obtenir le certificat wildcard manuellement (Certbot DNS-01, achetĂ©, etc.) et le charger dans Caddy : +```caddy +*.studioe5.edudeploy.com { + tls /data/certs/wildcard.crt /data/certs/wildcard.key + reverse_proxy resolver:2020 { + header_up Host {host} + } +} +``` + +InconvĂ©nient : renouvellement manuel. + ## 🔧 Notes techniques - Le conteneur `resolver-vpn` utilise `network_mode: service:resolver` pour partager le netns avec le resolver.