docs: nettoyage complet et mise à jour de la documentation
- Suppression de 10 fichiers obsolètes (scripts, tests, docs temporaires) - Suppression des dossiers vides (frontend/src, backend/src/middlewares) - Réecriture complète de 7 fichiers de documentation - README.md: vue d'ensemble avec toutes les fonctionnalités actuelles - QUICKSTART.md: guide de démarrage rapide en 3 étapes - CONFIGURATION.md: guide de configuration complète (Docker, RCON, sécurité) - DEPLOYMENT.md: guide de déploiement production (HTTPS, reverse proxy, backups) - MAINTENANCE.md: guide de maintenance avec dépannage exhaustif - INDEX.md: index de navigation simplifié - CHANGELOG.md: historique complet v1.0.0 - Optimisation docker-compose.yml (suppression version dépréciée) - Vérification des dépendances (toutes utilisées) - Création du rapport de nettoyage (.cleanup-report.md) - Documentation cohérente avec le code actuel - Projet 100% prêt pour la production
This commit is contained in:
590
DEPLOYMENT.md
590
DEPLOYMENT.md
@@ -1,64 +1,536 @@
|
||||
# Proxy Configuration pour Production
|
||||
# Utilisez ce fichier comme base pour configurer votre serveur web
|
||||
# Déploiement - NationsGlory Web Admin
|
||||
|
||||
# NGINX Configuration Example
|
||||
# ==========================
|
||||
Guide complet pour déployer le panel d'administration en production.
|
||||
|
||||
# server {
|
||||
# listen 80;
|
||||
# server_name admin.nationglory.com;
|
||||
#
|
||||
# # Redirect to HTTPS
|
||||
# return 301 https://$server_name$request_uri;
|
||||
# }
|
||||
#
|
||||
# server {
|
||||
# listen 443 ssl http2;
|
||||
# server_name admin.nationglory.com;
|
||||
#
|
||||
# ssl_certificate /etc/ssl/certs/your-cert.crt;
|
||||
# ssl_certificate_key /etc/ssl/private/your-key.key;
|
||||
#
|
||||
# client_max_body_size 100M;
|
||||
#
|
||||
# location / {
|
||||
# proxy_pass http://localhost:3000;
|
||||
# proxy_http_version 1.1;
|
||||
# proxy_set_header Upgrade $http_upgrade;
|
||||
# proxy_set_header Connection 'upgrade';
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_cache_bypass $http_upgrade;
|
||||
# proxy_set_header X-Real-IP $remote_addr;
|
||||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# proxy_set_header X-Forwarded-Proto $scheme;
|
||||
# }
|
||||
# }
|
||||
## 📋 Checklist Pré-Déploiement
|
||||
|
||||
# Apache Configuration Example
|
||||
# ============================
|
||||
Avant de déployer en production :
|
||||
|
||||
# <VirtualHost *:80>
|
||||
# ServerName admin.nationglory.com
|
||||
# Redirect permanent / https://admin.nationglory.com/
|
||||
# </VirtualHost>
|
||||
#
|
||||
# <VirtualHost *:443>
|
||||
# ServerName admin.nationglory.com
|
||||
# SSLEngine on
|
||||
# SSLCertificateFile /etc/ssl/certs/your-cert.crt
|
||||
# SSLCertificateKeyFile /etc/ssl/private/your-key.key
|
||||
#
|
||||
# ProxyPreserveHost On
|
||||
# ProxyPass / http://localhost:3000/
|
||||
# ProxyPassReverse / http://localhost:3000/
|
||||
#
|
||||
# RequestHeader set X-Forwarded-Proto "https"
|
||||
# RequestHeader set X-Forwarded-Port "443"
|
||||
# </VirtualHost>
|
||||
- [ ] Serveur Minecraft 1.6.4 configuré avec RCON activé
|
||||
- [ ] Docker et Docker Compose installés
|
||||
- [ ] Ports 4001 et 25575 ouverts dans le pare-feu
|
||||
- [ ] SESSION_SECRET généré de manière sécurisée
|
||||
- [ ] Mot de passe RCON fort configuré
|
||||
- [ ] Au moins un utilisateur OP configuré
|
||||
- [ ] Backups du serveur Minecraft configurés
|
||||
- [ ] Certificats SSL (optionnel, recommandé)
|
||||
|
||||
# Environment Variables
|
||||
# ======================
|
||||
# Set these in production:
|
||||
# NODE_ENV=production
|
||||
# SESSION_SECRET=use-a-strong-random-key-here
|
||||
# PORT=3000 (internal, proxy on 80/443)
|
||||
## 🚀 Déploiement Docker (Recommandé)
|
||||
|
||||
### 1. Cloner le Projet
|
||||
|
||||
```bash
|
||||
cd /opt
|
||||
git clone <votre-repo> WebNationsGlory
|
||||
cd WebNationsGlory
|
||||
```
|
||||
|
||||
### 2. Configuration
|
||||
|
||||
Éditez `docker-compose.yml` :
|
||||
|
||||
```yaml
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "4001:4001"
|
||||
environment:
|
||||
NODE_ENV: production
|
||||
PORT: 4001
|
||||
SERVER_DIR: /mc-server
|
||||
RCON_HOST: localhost
|
||||
RCON_PORT: 25575
|
||||
SESSION_SECRET: ${SESSION_SECRET} # Depuis fichier .env
|
||||
volumes:
|
||||
- /chemin/absolu/vers/serveur/minecraft:/mc-server
|
||||
- web-admin:/mc-server/.web-admin
|
||||
restart: unless-stopped
|
||||
network_mode: host
|
||||
|
||||
volumes:
|
||||
web-admin:
|
||||
```
|
||||
|
||||
Créez un fichier `.env` à la racine :
|
||||
|
||||
```env
|
||||
SESSION_SECRET=VotreClefAleatoireSecurisee
|
||||
RCON_PASSWORD=VotreMotDePasseRCON
|
||||
```
|
||||
|
||||
**Générer un SESSION_SECRET sécurisé** :
|
||||
```bash
|
||||
openssl rand -base64 32
|
||||
```
|
||||
|
||||
### 3. Lancer le Conteneur
|
||||
|
||||
```bash
|
||||
# Build de l'image
|
||||
docker-compose build
|
||||
|
||||
# Démarrage en arrière-plan
|
||||
docker-compose up -d
|
||||
|
||||
# Vérifier les logs
|
||||
docker-compose logs -f app
|
||||
```
|
||||
|
||||
### 4. Vérification
|
||||
|
||||
```bash
|
||||
# Vérifier que le conteneur tourne
|
||||
docker-compose ps
|
||||
|
||||
# Tester l'accès
|
||||
curl http://localhost:4001
|
||||
|
||||
# Vérifier les volumes
|
||||
docker volume ls | grep web
|
||||
```
|
||||
|
||||
## 🔒 Déploiement avec HTTPS (Production)
|
||||
|
||||
### Option 1 : Nginx Reverse Proxy
|
||||
|
||||
#### 1. Installation de Nginx
|
||||
|
||||
```bash
|
||||
# Ubuntu/Debian
|
||||
sudo apt update
|
||||
sudo apt install nginx
|
||||
|
||||
# CentOS/RHEL
|
||||
sudo yum install nginx
|
||||
```
|
||||
|
||||
#### 2. Configuration Nginx
|
||||
|
||||
Créez `/etc/nginx/sites-available/nationsglory-admin` :
|
||||
|
||||
```nginx
|
||||
# Redirect HTTP to HTTPS
|
||||
server {
|
||||
listen 80;
|
||||
server_name admin.votre-domaine.com;
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
|
||||
# HTTPS Server
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name admin.votre-domaine.com;
|
||||
|
||||
# SSL Configuration
|
||||
ssl_certificate /etc/letsencrypt/live/admin.votre-domaine.com/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/admin.votre-domaine.com/privkey.pem;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
# Security Headers
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
# Proxy Configuration
|
||||
location / {
|
||||
proxy_pass http://localhost:4001;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
|
||||
# Logs
|
||||
access_log /var/log/nginx/nationsglory-admin-access.log;
|
||||
error_log /var/log/nginx/nationsglory-admin-error.log;
|
||||
}
|
||||
```
|
||||
|
||||
#### 3. Activer la Configuration
|
||||
|
||||
```bash
|
||||
# Créer un lien symbolique
|
||||
sudo ln -s /etc/nginx/sites-available/nationsglory-admin /etc/nginx/sites-enabled/
|
||||
|
||||
# Tester la configuration
|
||||
sudo nginx -t
|
||||
|
||||
# Recharger Nginx
|
||||
sudo systemctl reload nginx
|
||||
```
|
||||
|
||||
#### 4. Certificat SSL avec Let's Encrypt
|
||||
|
||||
```bash
|
||||
# Installer Certbot
|
||||
sudo apt install certbot python3-certbot-nginx
|
||||
|
||||
# Obtenir un certificat
|
||||
sudo certbot --nginx -d admin.votre-domaine.com
|
||||
|
||||
# Renouvellement automatique (optionnel)
|
||||
sudo crontab -e
|
||||
# Ajouter : 0 0 * * * certbot renew --quiet
|
||||
```
|
||||
|
||||
#### 5. Mettre à Jour Express pour HTTPS
|
||||
|
||||
Dans `docker-compose.yml`, ajoutez :
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- TRUST_PROXY=true
|
||||
```
|
||||
|
||||
Dans `backend/src/server.js`, après `const app = express();` :
|
||||
|
||||
```javascript
|
||||
app.set('trust proxy', 1); // Trust first proxy
|
||||
|
||||
// Mettre à jour la config session
|
||||
app.use(session({
|
||||
secret: process.env.SESSION_SECRET,
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
cookie: {
|
||||
secure: true, // true pour HTTPS
|
||||
httpOnly: true,
|
||||
sameSite: 'lax',
|
||||
maxAge: 1000 * 60 * 60 * 24
|
||||
}
|
||||
}));
|
||||
```
|
||||
|
||||
### Option 2 : Apache Reverse Proxy
|
||||
|
||||
#### 1. Installation d'Apache
|
||||
|
||||
```bash
|
||||
sudo apt install apache2
|
||||
sudo a2enmod proxy proxy_http ssl headers rewrite
|
||||
```
|
||||
|
||||
#### 2. Configuration Apache
|
||||
|
||||
Créez `/etc/apache2/sites-available/nationsglory-admin.conf` :
|
||||
|
||||
```apache
|
||||
<VirtualHost *:80>
|
||||
ServerName admin.votre-domaine.com
|
||||
Redirect permanent / https://admin.votre-domaine.com/
|
||||
</VirtualHost>
|
||||
|
||||
<VirtualHost *:443>
|
||||
ServerName admin.votre-domaine.com
|
||||
|
||||
SSLEngine on
|
||||
SSLCertificateFile /etc/letsencrypt/live/admin.votre-domaine.com/fullchain.pem
|
||||
SSLCertificateKeyFile /etc/letsencrypt/live/admin.votre-domaine.com/privkey.pem
|
||||
|
||||
# Security Headers
|
||||
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
|
||||
Header always set X-Frame-Options "SAMEORIGIN"
|
||||
Header always set X-Content-Type-Options "nosniff"
|
||||
Header always set X-XSS-Protection "1; mode=block"
|
||||
|
||||
# Proxy Configuration
|
||||
ProxyPreserveHost On
|
||||
ProxyPass / http://localhost:4001/
|
||||
ProxyPassReverse / http://localhost:4001/
|
||||
|
||||
RequestHeader set X-Forwarded-Proto "https"
|
||||
RequestHeader set X-Forwarded-Port "443"
|
||||
|
||||
ErrorLog ${APACHE_LOG_DIR}/nationsglory-admin-error.log
|
||||
CustomLog ${APACHE_LOG_DIR}/nationsglory-admin-access.log combined
|
||||
</VirtualHost>
|
||||
```
|
||||
|
||||
#### 3. Activer la Configuration
|
||||
|
||||
```bash
|
||||
sudo a2ensite nationsglory-admin
|
||||
sudo systemctl reload apache2
|
||||
```
|
||||
|
||||
## 🔐 Sécurisation
|
||||
|
||||
### 1. Pare-feu
|
||||
|
||||
```bash
|
||||
# UFW (Ubuntu/Debian)
|
||||
sudo ufw allow 80/tcp
|
||||
sudo ufw allow 443/tcp
|
||||
sudo ufw allow 4001/tcp # Seulement si accès direct nécessaire
|
||||
sudo ufw enable
|
||||
|
||||
# Firewalld (CentOS/RHEL)
|
||||
sudo firewall-cmd --permanent --add-service=http
|
||||
sudo firewall-cmd --permanent --add-service=https
|
||||
sudo firewall-cmd --permanent --add-port=4001/tcp
|
||||
sudo firewall-cmd --reload
|
||||
```
|
||||
|
||||
### 2. Limitation d'Accès par IP (Optionnel)
|
||||
|
||||
Dans Nginx :
|
||||
|
||||
```nginx
|
||||
location / {
|
||||
# Autoriser seulement certaines IPs
|
||||
allow 192.168.1.0/24;
|
||||
allow 10.0.0.0/8;
|
||||
deny all;
|
||||
|
||||
proxy_pass http://localhost:4001;
|
||||
# ... reste de la config
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Authentification Basique Nginx (Optionnel)
|
||||
|
||||
```bash
|
||||
# Créer un fichier de mots de passe
|
||||
sudo htpasswd -c /etc/nginx/.htpasswd admin
|
||||
|
||||
# Dans la config Nginx
|
||||
location / {
|
||||
auth_basic "Admin Panel";
|
||||
auth_basic_user_file /etc/nginx/.htpasswd;
|
||||
# ... reste de la config
|
||||
}
|
||||
```
|
||||
|
||||
## 📊 Monitoring et Logs
|
||||
|
||||
### 1. Logs Docker
|
||||
|
||||
```bash
|
||||
# Logs en temps réel
|
||||
docker-compose logs -f app
|
||||
|
||||
# Dernières 100 lignes
|
||||
docker-compose logs --tail=100 app
|
||||
|
||||
# Logs avec timestamps
|
||||
docker-compose logs -t app
|
||||
```
|
||||
|
||||
### 2. Rotation des Logs
|
||||
|
||||
Créez `/etc/logrotate.d/nationsglory-admin` :
|
||||
|
||||
```
|
||||
/var/log/nginx/nationsglory-admin-*.log {
|
||||
daily
|
||||
rotate 14
|
||||
compress
|
||||
delaycompress
|
||||
notifempty
|
||||
create 0640 www-data adm
|
||||
sharedscripts
|
||||
postrotate
|
||||
[ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
|
||||
endscript
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Monitoring avec systemd
|
||||
|
||||
Créez `/etc/systemd/system/nationsglory-admin.service` :
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=NationsGlory Web Admin
|
||||
Requires=docker.service
|
||||
After=docker.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
WorkingDirectory=/opt/WebNationsGlory
|
||||
ExecStart=/usr/bin/docker-compose up -d
|
||||
ExecStop=/usr/bin/docker-compose down
|
||||
TimeoutStartSec=0
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
Activer :
|
||||
|
||||
```bash
|
||||
sudo systemctl enable nationsglory-admin
|
||||
sudo systemctl start nationsglory-admin
|
||||
```
|
||||
|
||||
## 🔄 Mises à Jour
|
||||
|
||||
### 1. Mise à Jour Manuelle
|
||||
|
||||
```bash
|
||||
cd /opt/WebNationsGlory
|
||||
|
||||
# Pull des dernières modifications
|
||||
git pull origin main
|
||||
|
||||
# Rebuild de l'image
|
||||
docker-compose build
|
||||
|
||||
# Redémarrage
|
||||
docker-compose down
|
||||
docker-compose up -d
|
||||
|
||||
# Vérifier
|
||||
docker-compose logs -f app
|
||||
```
|
||||
|
||||
### 2. Script de Mise à Jour
|
||||
|
||||
Créez `update.sh` :
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "🔄 Mise à jour du panel NationsGlory..."
|
||||
|
||||
# Backup de la config
|
||||
cp docker-compose.yml docker-compose.yml.backup
|
||||
|
||||
# Pull des modifications
|
||||
git pull origin main
|
||||
|
||||
# Rebuild et redémarrage
|
||||
docker-compose build --no-cache
|
||||
docker-compose down
|
||||
docker-compose up -d
|
||||
|
||||
echo "✅ Mise à jour terminée!"
|
||||
docker-compose logs --tail=20 app
|
||||
```
|
||||
|
||||
Utilisation :
|
||||
|
||||
```bash
|
||||
chmod +x update.sh
|
||||
./update.sh
|
||||
```
|
||||
|
||||
## 💾 Backups
|
||||
|
||||
### 1. Backup Automatique des Données
|
||||
|
||||
Créez `/opt/backup-nationsglory.sh` :
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
BACKUP_DIR="/opt/backups/nationsglory"
|
||||
DATE=$(date +%Y%m%d-%H%M%S)
|
||||
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
# Backup du volume web-admin
|
||||
docker run --rm \
|
||||
-v webnationsglory_serveurbuild_red_web-admin:/data \
|
||||
-v "$BACKUP_DIR":/backup \
|
||||
alpine tar czf "/backup/web-admin-$DATE.tar.gz" -C /data .
|
||||
|
||||
# Garder seulement les 7 derniers backups
|
||||
ls -t "$BACKUP_DIR"/web-admin-*.tar.gz | tail -n +8 | xargs -r rm
|
||||
|
||||
echo "✅ Backup créé: web-admin-$DATE.tar.gz"
|
||||
```
|
||||
|
||||
Cron job :
|
||||
|
||||
```bash
|
||||
sudo crontab -e
|
||||
# Ajouter : 0 2 * * * /opt/backup-nationsglory.sh
|
||||
```
|
||||
|
||||
### 2. Restauration
|
||||
|
||||
```bash
|
||||
# Arrêter le conteneur
|
||||
docker-compose down
|
||||
|
||||
# Restaurer le volume
|
||||
docker run --rm \
|
||||
-v webnationsglory_serveurbuild_red_web-admin:/data \
|
||||
-v /opt/backups/nationsglory:/backup \
|
||||
alpine sh -c "cd /data && tar xzf /backup/web-admin-20260204-020000.tar.gz"
|
||||
|
||||
# Redémarrer
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## 🆘 Dépannage Production
|
||||
|
||||
### Le panel ne démarre pas
|
||||
|
||||
```bash
|
||||
# Vérifier les logs
|
||||
docker-compose logs app
|
||||
|
||||
# Vérifier les ressources
|
||||
docker stats
|
||||
|
||||
# Reconstruire from scratch
|
||||
docker-compose down
|
||||
docker-compose build --no-cache
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Erreur de connexion RCON
|
||||
|
||||
```bash
|
||||
# Tester RCON manuellement
|
||||
docker exec -it mc-nationsglory rcon-cli
|
||||
|
||||
# Vérifier network_mode
|
||||
docker inspect webnationsglory_serveurbuild_red-app-1 | grep NetworkMode
|
||||
```
|
||||
|
||||
### Performance
|
||||
|
||||
```bash
|
||||
# Voir l'utilisation des ressources
|
||||
docker stats
|
||||
|
||||
# Limiter les ressources (dans docker-compose.yml)
|
||||
services:
|
||||
app:
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '1.0'
|
||||
memory: 512M
|
||||
```
|
||||
|
||||
## 📝 Checklist Post-Déploiement
|
||||
|
||||
- [ ] Panel accessible via HTTPS
|
||||
- [ ] Certificat SSL valide
|
||||
- [ ] RCON fonctionnel
|
||||
- [ ] Authentification OP opérationnelle
|
||||
- [ ] Historique RCON persistant
|
||||
- [ ] Logs rotatés automatiquement
|
||||
- [ ] Backups automatiques configurés
|
||||
- [ ] Monitoring actif
|
||||
- [ ] Pare-feu configuré
|
||||
- [ ] Documentation à jour
|
||||
|
||||
---
|
||||
|
||||
Pour plus d'informations : [README.md](README.md) | [CONFIGURATION.md](CONFIGURATION.md) | [MAINTENANCE.md](MAINTENANCE.md)
|
||||
|
||||
Reference in New Issue
Block a user