326 lines
9.4 KiB
Markdown
326 lines
9.4 KiB
Markdown
# 🖥️ SERVER.md — Documentation du serveur `lespotitschats`
|
|
|
|
> Dernière mise à jour : Juillet 2026
|
|
> À maintenir à jour après chaque modification majeure.
|
|
|
|
---
|
|
|
|
## 📡 Accès
|
|
|
|
| Champ | Valeur |
|
|
|---------------|---------------------------------|
|
|
| IP locale | 192.168.1.54 |
|
|
| IP Tailscale | 100.102.240.59 |
|
|
| Hostname | lespotitschats |
|
|
| User SSH | vohorgeez |
|
|
| OS | Ubuntu 24.04 LTS |
|
|
| Matériel | Predator Helios 300 (laptop) |
|
|
| GPU | NVIDIA GTX 1050 Ti (driver 535) |
|
|
|
|
```bash
|
|
# En local
|
|
ssh vohorgeez@192.168.1.54
|
|
|
|
# À distance (via Tailscale)
|
|
ssh vohorgeez@100.102.240.59
|
|
```
|
|
|
|
---
|
|
|
|
## 🌐 Architecture réseau
|
|
|
|
```
|
|
Internet
|
|
↓
|
|
VPS Hetzner (178.105.251.219) ← Caddy (reverse proxy + HTTPS auto)
|
|
↕ Tunnel WireGuard (10.0.0.1 ↔ 10.0.0.2)
|
|
lespotitschats (192.168.1.54)
|
|
└── Box SFR (CGNAT — pas d'IPv4 publique dédiée)
|
|
```
|
|
|
|
**Accès distant :**
|
|
- Services publics → via sous-domaines `*.mathieuvergez.com` (DNS Wix → VPS)
|
|
- SSH → via Tailscale (`100.102.240.59`)
|
|
- Portainer → via Tailscale uniquement (`https://100.102.240.59:9443`)
|
|
|
|
---
|
|
|
|
## 🐳 Services Docker
|
|
|
|
| Service | Image | Port local | URL publique | Notes |
|
|
|---------------|------------------------------|------------|---------------------------------------|------------------------------------|
|
|
| Jellyfin | jellyfin/jellyfin | :8096 | https://jellyfin.mathieuvergez.com | NVENC activé (H264/HEVC) |
|
|
| Nextcloud | nextcloud | :8080 | https://cloud.mathieuvergez.com | Données sur `/mnt/storage/nextcloud` |
|
|
| Nextcloud DB | mariadb:10.6 | interne | — | Réseau `nextcloud-net` |
|
|
| Gitea | gitea/gitea | :3000/:222 | https://git.mathieuvergez.com | :222 = SSH Git |
|
|
| Portainer | portainer/portainer-ce:sts | :9443 | Tailscale uniquement | HTTPS, accès privé |
|
|
| mnist-app | mnist-app (local) | :8501 | https://mnist.mathieuvergez.com | App ML, Streamlit |
|
|
|
|
---
|
|
|
|
## 🖥️ VPS Hetzner
|
|
|
|
| Champ | Valeur |
|
|
|------------|---------------------------|
|
|
| IP | 178.105.251.219 |
|
|
| OS | Ubuntu 24.04 |
|
|
| Specs | CX23 — 2 vCPU, 4 GB RAM |
|
|
| Localisation | Falkenstein, Allemagne |
|
|
| Coût | ~4.79€/mois |
|
|
|
|
**Services sur le VPS :**
|
|
- Caddy — reverse proxy + HTTPS automatique (Let's Encrypt)
|
|
- WireGuard — tunnel vers `lespotitschats`
|
|
|
|
```bash
|
|
# Se connecter au VPS
|
|
ssh root@178.105.251.219
|
|
|
|
# Modifier le reverse proxy
|
|
nano /etc/caddy/Caddyfile
|
|
systemctl reload caddy
|
|
|
|
# Statut WireGuard
|
|
wg show
|
|
```
|
|
|
|
---
|
|
|
|
## 🌍 DNS (Wix)
|
|
|
|
Tous les enregistrements A pointent vers `178.105.251.219` :
|
|
|
|
| Sous-domaine | Destination |
|
|
|--------------|---------------------|
|
|
| jellyfin | VPS → lespotitschats:8096 |
|
|
| cloud | VPS → lespotitschats:8080 |
|
|
| git | VPS → lespotitschats:3000 |
|
|
| mnist | VPS → lespotitschats:8501 |
|
|
| morpion | Fichiers statiques sur VPS |
|
|
|
|
> ⚠️ Les nameservers Wix ne peuvent pas être changés — on utilise des enregistrements A individuels.
|
|
|
|
---
|
|
|
|
## 💾 Stockage
|
|
|
|
| Chemin | Disque | Taille | Contenu |
|
|
|--------------------|------------|--------|----------------------------------|
|
|
| `/` | /dev/sdb3 | 100 GB | Système Ubuntu + Docker |
|
|
| `/mnt/storage` | /dev/sdc2 | 3.6 TB | Données Nextcloud, médias Jellyfin |
|
|
| `/data/media` | symlink | — | → `/mnt/storage/media` |
|
|
|
|
**Montage automatique** via `/etc/fstab` (UUID `8ff71e6e-...`).
|
|
|
|
---
|
|
|
|
## 🎬 Jellyfin — Notes importantes
|
|
|
|
- **NVENC activé** : encode en H264 via GPU (GTX 1050 Ti)
|
|
- **Décodage hardware** : H264 et HEVC uniquement (pas MPEG4/DivX)
|
|
- **Conversion automatique** : script cron à 2h chaque nuit convertit les `.avi` → `.mkv` H264
|
|
- Script : `/usr/local/bin/convert_avi.sh`
|
|
- Logs : `/var/log/jellyfin_convert.log`
|
|
- **Médias** : `/mnt/storage/media/movies` et `/mnt/storage/media/shows`
|
|
|
|
---
|
|
|
|
## 🔧 Services système
|
|
|
|
| Service | Rôle |
|
|
|----------------------|---------------------------------------|
|
|
| WireGuard (wg0) | Tunnel VPN vers VPS |
|
|
| Tailscale | Accès distant privé |
|
|
| nvidia-persistenced | Driver GPU NVIDIA |
|
|
| fail2ban | Protection brute-force SSH |
|
|
| netdata | Monitoring infra |
|
|
| docker | Runtime containers |
|
|
| cron | Tâches planifiées (conversion AVI) |
|
|
|
|
---
|
|
|
|
## 🔐 Accès à distance
|
|
|
|
### Via Tailscale (recommandé)
|
|
```bash
|
|
ssh vohorgeez@100.102.240.59
|
|
```
|
|
|
|
### Portainer (admin Docker)
|
|
```
|
|
https://100.102.240.59:9443
|
|
```
|
|
⚠️ Certificat auto-signé → accepter l'exception de sécurité.
|
|
|
|
---
|
|
|
|
## 🔄 Procédures courantes
|
|
|
|
### Redémarrer un container
|
|
```bash
|
|
docker restart <nom>
|
|
# Exemples :
|
|
docker restart jellyfin
|
|
docker restart nextcloud
|
|
docker restart gitea
|
|
```
|
|
|
|
### Voir les logs
|
|
```bash
|
|
docker logs <nom> --tail 50 -f
|
|
```
|
|
|
|
### Vérifier l'état après reboot
|
|
```bash
|
|
docker ps # tous les containers up ?
|
|
df -h | grep mnt # disque storage monté ?
|
|
sudo wg show # tunnel WireGuard actif ?
|
|
nvidia-smi # GPU reconnu ?
|
|
```
|
|
|
|
### Monter le disque storage manuellement (si pas auto)
|
|
```bash
|
|
sudo mount /mnt/storage
|
|
```
|
|
|
|
### Ajouter un nouveau service exposé publiquement
|
|
1. Lancer le container sur `lespotitschats`
|
|
2. Sur le VPS : ajouter un bloc dans `/etc/caddy/Caddyfile`
|
|
3. `systemctl reload caddy`
|
|
4. Ajouter un enregistrement A dans Wix → `178.105.251.219`
|
|
5. Documenter ici
|
|
|
|
---
|
|
|
|
## ⚙️ Gitea — Miroir vers GitHub
|
|
|
|
Tous les repos Gitea sont mirroirs vers GitHub (`vohorgeez`).
|
|
La synchronisation est automatique à chaque push.
|
|
|
|
**Ajouter un miroir sur un nouveau repo :**
|
|
Gitea → repo → Paramètres → Miroirs → Ajouter un miroir push
|
|
- URL : `https://github.com/vohorgeez/<repo>.git`
|
|
- Login : `vohorgeez`
|
|
- Mot de passe : token GitHub (scope `repo`)
|
|
|
|
---
|
|
|
|
## 🌡️ Thermique
|
|
|
|
Le serveur est un laptop Predator Helios 300 — températures normales en charge :
|
|
- CPU au repos : ~70°C
|
|
- GPU en transcodage : ~80°C
|
|
|
|
**À faire :** changer la pâte thermique (prévu).
|
|
|
|
---
|
|
|
|
## ⚠️ Points de vigilance
|
|
|
|
- **CGNAT SFR** : pas d'IPv4 publique dédiée → tout passe par le VPS
|
|
- **Secure Boot** : désactivé (nécessaire pour le driver NVIDIA)
|
|
- **Disque `/mnt/storage`** : vérifier le montage après chaque reboot
|
|
- **Portainer** : ne jamais exposer publiquement
|
|
- **Gitea ROOT_URL** : `https://git.mathieuvergez.com/`
|
|
|
|
---
|
|
|
|
## 📌 TODO
|
|
|
|
- [ ] Changer la pâte thermique du Predator
|
|
- [ ] Installer Tailscale sur le laptop (das-komputer)
|
|
- [ ] Mettre en place sauvegardes automatiques
|
|
- [ ] CI/CD : webhook Gitea → déploiement auto
|
|
|
|
---
|
|
|
|
## 🔗 Infrastructure Webhook (CI/CD)
|
|
|
|
Le serveur webhook écoute sur le VPS et déclenche des déploiements automatiques quand Gitea pousse une notification.
|
|
|
|
**URL publique :** `https://deploy.mathieuvergez.com/hooks/<nom-du-hook>`
|
|
|
|
### Architecture
|
|
|
|
```
|
|
Push sur Gitea
|
|
↓
|
|
Gitea envoie POST → https://deploy.mathieuvergez.com/hooks/<projet>
|
|
↓
|
|
webhook (VPS port 9000, via Caddy)
|
|
↓
|
|
Script de déploiement spécifique au projet
|
|
```
|
|
|
|
### Fichiers importants (sur le VPS)
|
|
|
|
| Fichier | Rôle |
|
|
|---|---|
|
|
| `/etc/webhook.conf` | Config active lue par le service |
|
|
| `/etc/webhook/hooks.json` | Fichier de travail — ajouter les hooks ici |
|
|
| `/usr/local/bin/deploy-*.sh` | Scripts de déploiement par projet |
|
|
|
|
### Ajouter un hook pour un nouveau projet
|
|
|
|
**1. Créer le script de déploiement sur le VPS**
|
|
|
|
```bash
|
|
nano /usr/local/bin/deploy-monprojet.sh
|
|
chmod +x /usr/local/bin/deploy-monprojet.sh
|
|
```
|
|
|
|
**2. Ajouter l'entrée dans `/etc/webhook/hooks.json`**
|
|
|
|
```json
|
|
[
|
|
{
|
|
"id": "monprojet",
|
|
"execute-command": "/usr/local/bin/deploy-monprojet.sh",
|
|
"command-working-directory": "/var/www/monprojet",
|
|
"trigger-rule": {
|
|
"match": {
|
|
"type": "payload-hmac-sha256",
|
|
"secret": "MON_SECRET",
|
|
"parameter": {
|
|
"source": "header",
|
|
"name": "X-Gitea-Signature-256"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
```
|
|
|
|
**3. Appliquer la config**
|
|
|
|
```bash
|
|
cp /etc/webhook/hooks.json /etc/webhook.conf
|
|
systemctl restart webhook
|
|
```
|
|
|
|
**4. Configurer le webhook dans Gitea**
|
|
|
|
Gitea → repo → Paramètres → Webhooks → Ajouter webhook → Gitea
|
|
- URL : `https://deploy.mathieuvergez.com/hooks/monprojet`
|
|
- Secret : `MON_SECRET` (même valeur que dans hooks.json)
|
|
- Événements : `Push`
|
|
|
|
### Projet statique (VPS) — template de script
|
|
|
|
```bash
|
|
#!/bin/bash
|
|
cd /var/www/monprojet
|
|
git pull origin main
|
|
```
|
|
|
|
### Projet Docker (lespotitschats) — template de script
|
|
|
|
```bash
|
|
#!/bin/bash
|
|
cd /home/vohorgeez/monprojet
|
|
git pull origin main
|
|
docker build -t monprojet .
|
|
docker stop monprojet || true
|
|
docker rm monprojet || true
|
|
docker run -d --name monprojet --restart unless-stopped -p PORT:PORT monprojet
|
|
``` |