Actualiser SERVER.md
This commit is contained in:
359
SERVER.md
359
SERVER.md
@@ -1,6 +1,6 @@
|
||||
# 🖥️ SERVER.md — Documentation du serveur `lespotitschats`
|
||||
|
||||
> Dernière mise à jour : Avril 2026
|
||||
> Dernière mise à jour : Juillet 2026
|
||||
> À maintenir à jour après chaque modification majeure.
|
||||
|
||||
---
|
||||
@@ -8,154 +8,319 @@
|
||||
## 📡 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
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🐳 Services Docker (état réel)
|
||||
## 🌐 Architecture réseau
|
||||
|
||||
| Service | Image | Port exposé | URL locale | Notes |
|
||||
|----------------|----------------------------|-------------|----------------------------- |------------------------------|
|
||||
| Jellyfin | jellyfin/jellyfin | :8096 | http://192.168.1.54:8096 | Media server, healthy |
|
||||
| Nextcloud | nextcloud | :8080 | http://192.168.1.54:8080 | Cloud perso |
|
||||
| Nextcloud DB | mariadb:10.6 | interne | — | Ne pas exposer |
|
||||
| Gitea | gitea/gitea | :3000 / :222| http://192.168.1.54:3000 | :222 = SSH Git |
|
||||
| Portainer | portainer/portainer-ce:sts | :9443 | https://192.168.1.54:9443 | ⚠️ HTTPS uniquement |
|
||||
| PostgreSQL | postgres:17 | :5432 | — | ⚠️ Exposé — à restreindre |
|
||||
| mnist-app | mnist-app (local) | :8501 | http://192.168.1.54:8501 | App ML perso |
|
||||
```
|
||||
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 système actifs
|
||||
## 🐳 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 |
|
||||
|-------------------|---------------------------------------|
|
||||
| nginx | Reverse proxy |
|
||||
|----------------------|---------------------------------------|
|
||||
| WireGuard (wg0) | Tunnel VPN vers VPS |
|
||||
| Tailscale | Accès distant privé |
|
||||
| nvidia-persistenced | Driver GPU NVIDIA |
|
||||
| fail2ban | Protection brute-force SSH |
|
||||
| netdata | Monitoring infra (interface web) |
|
||||
| ssh | Accès distant |
|
||||
| netdata | Monitoring infra |
|
||||
| docker | Runtime containers |
|
||||
| unattended-upgrades | MAJ sécurité automatiques |
|
||||
| cron | Tâches planifiées (conversion AVI) |
|
||||
|
||||
---
|
||||
|
||||
## 📁 Dossiers importants
|
||||
|
||||
```
|
||||
/data/media → Fichiers Jellyfin (films, séries, musique)
|
||||
/data/cloud → Données Nextcloud
|
||||
/data/backups → Sauvegardes
|
||||
/data/projects → Projets perso / code
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Procédures
|
||||
|
||||
### Redémarrer un service Docker
|
||||
## 🔐 Accès à distance
|
||||
|
||||
### Via Tailscale (recommandé)
|
||||
```bash
|
||||
docker restart <nom_du_container>
|
||||
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 d'un container
|
||||
|
||||
### Voir les logs
|
||||
```bash
|
||||
docker logs <nom_du_container> --tail 50 -f
|
||||
docker logs <nom> --tail 50 -f
|
||||
```
|
||||
|
||||
### Arrêter / relancer tous les containers
|
||||
|
||||
### Vérifier l'état après reboot
|
||||
```bash
|
||||
docker stop $(docker ps -q)
|
||||
docker start $(docker ps -a -q)
|
||||
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
|
||||
|
||||
---
|
||||
|
||||
### Ajouter un nouveau service Docker
|
||||
## ⚙️ Gitea — Miroir vers GitHub
|
||||
|
||||
1. Crée un dossier dans `/data/projects/nom_service/`
|
||||
2. Ajoute un `docker-compose.yml`
|
||||
3. Lance :
|
||||
Tous les repos Gitea sont mirroirs vers GitHub (`vohorgeez`).
|
||||
La synchronisation est automatique à chaque push.
|
||||
|
||||
```bash
|
||||
cd /data/projects/nom_service
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
4. Configure nginx si tu veux un reverse proxy :
|
||||
|
||||
```bash
|
||||
sudo nano /etc/nginx/sites-available/nom_service
|
||||
sudo ln -s /etc/nginx/sites-available/nom_service /etc/nginx/sites-enabled/
|
||||
sudo nginx -t && sudo systemctl reload nginx
|
||||
```
|
||||
|
||||
5. **Documente le service dans ce fichier.**
|
||||
**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`)
|
||||
|
||||
---
|
||||
|
||||
### Sauvegarder manuellement
|
||||
## 🌡️ Thermique
|
||||
|
||||
```bash
|
||||
# Nextcloud
|
||||
docker exec nextcloud php occ maintenance:mode --on
|
||||
tar -czf /data/backups/nextcloud_$(date +%F).tar.gz /data/cloud
|
||||
docker exec nextcloud php occ maintenance:mode --off
|
||||
Le serveur est un laptop Predator Helios 300 — températures normales en charge :
|
||||
- CPU au repos : ~70°C
|
||||
- GPU en transcodage : ~80°C
|
||||
|
||||
# Gitea
|
||||
docker exec gitea gitea dump -c /data/gitea/conf/app.ini
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Redémarrer le serveur proprement
|
||||
|
||||
```bash
|
||||
# Vérifier que tout est propre avant
|
||||
docker ps
|
||||
sudo systemctl status nginx
|
||||
|
||||
# Reboot
|
||||
sudo reboot
|
||||
```
|
||||
|
||||
**Après reboot, vérifier :**
|
||||
|
||||
```bash
|
||||
docker ps # tous les containers sont up ?
|
||||
curl http://localhost:8096 # Jellyfin
|
||||
curl http://localhost:8080 # Nextcloud
|
||||
curl http://localhost:3000 # Gitea
|
||||
```
|
||||
**À faire :** changer la pâte thermique (prévu).
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ Points de vigilance
|
||||
|
||||
- `postgres` est exposé sur `:5432` → restreindre avec un firewall ou le mettre en réseau Docker interne uniquement
|
||||
- `Portainer` est en HTTPS sur `:9443` (pas `:9000`)
|
||||
- `fail2ban` est actif → 3 échecs SSH = bannissement
|
||||
- **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 / Améliorations futures
|
||||
## 📌 TODO
|
||||
|
||||
- [ ] Restreindre PostgreSQL au réseau Docker interne
|
||||
- [ ] Mettre en place des sauvegardes automatiques (cron)
|
||||
- [ ] Configurer les sous-domaines nginx pour chaque service
|
||||
- [ ] Ajouter monitoring des volumes disque
|
||||
- [ ] 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
|
||||
```
|
||||
Reference in New Issue
Block a user