All checks were successful
Auto Tag Develop / tag (push) Successful in 8s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
154 lines
3.6 KiB
Markdown
154 lines
3.6 KiB
Markdown
# Configuration du mode maintenance (nginx hote)
|
|
|
|
Guide pour activer le support du mode maintenance pilote par Central.
|
|
Ces etapes sont a faire **une seule fois** par application sur le serveur de production.
|
|
|
|
Le principe : le nginx de l'hote (reverse proxy) verifie si un fichier `maintenance.on` existe dans le dossier de deploy. Si oui, il sert une page `maintenance.html` au lieu de proxifier vers le container Docker.
|
|
|
|
Central pilote la creation/suppression de ce fichier via ses volumes Docker.
|
|
|
|
## Ce qui a ete fait pour Lesstime
|
|
|
|
### 1. Deployer pour extraire la page maintenance
|
|
|
|
```bash
|
|
cd /var/www/lesstime
|
|
sudo ./deploy.sh
|
|
```
|
|
|
|
Le `deploy.sh` extrait automatiquement `maintenance.html` du container vers `public/` :
|
|
```
|
|
mkdir -p public
|
|
sudo docker compose cp app:/var/www/html/public/maintenance.html public/maintenance.html
|
|
```
|
|
|
|
### 2. Mettre a jour la conf nginx de l'hote
|
|
|
|
Remplacer le contenu de `/etc/nginx/sites-available/lesstime.conf` :
|
|
|
|
```nginx
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name project.malio-dev.fr;
|
|
|
|
root /var/www/lesstime/public;
|
|
|
|
# Maintenance mode
|
|
if (-f /var/www/lesstime/maintenance.on) {
|
|
return 503;
|
|
}
|
|
|
|
error_page 503 @maintenance;
|
|
|
|
location @maintenance {
|
|
rewrite ^(.*)$ /maintenance.html break;
|
|
}
|
|
|
|
location = /maintenance.html {
|
|
internal;
|
|
}
|
|
|
|
location / {
|
|
proxy_pass http://127.0.0.1:8081;
|
|
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;
|
|
client_max_body_size 55m;
|
|
}
|
|
}
|
|
```
|
|
|
|
### 3. Recharger nginx
|
|
|
|
```bash
|
|
sudo nginx -t && sudo systemctl reload nginx
|
|
```
|
|
|
|
### 4. Verifier
|
|
|
|
- Depuis Central, activer la maintenance sur Lesstime
|
|
- Ouvrir `http://project.malio-dev.fr` → doit afficher la page "Maintenance en cours"
|
|
- Desactiver la maintenance depuis Central → le site revient
|
|
|
|
---
|
|
|
|
## A faire pour Inventory
|
|
|
|
Meme procedure :
|
|
|
|
### 1. Deployer pour extraire la page maintenance
|
|
|
|
```bash
|
|
cd /var/www/inventory
|
|
sudo ./deploy.sh
|
|
```
|
|
|
|
> Si le `deploy.sh` ne contient pas encore l'extraction, mettre a jour le fichier depuis le repo (`infra/prod/deploy.sh`) ou executer manuellement :
|
|
> ```bash
|
|
> mkdir -p public
|
|
> sudo docker compose cp app:/var/www/html/public/maintenance.html public/maintenance.html
|
|
> ```
|
|
|
|
### 2. Mettre a jour la conf nginx de l'hote
|
|
|
|
Remplacer le contenu de `/etc/nginx/sites-available/inventory.conf` :
|
|
|
|
```nginx
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name inventory.malio-dev.fr;
|
|
|
|
root /var/www/inventory/public;
|
|
|
|
# Maintenance mode
|
|
if (-f /var/www/inventory/maintenance.on) {
|
|
return 503;
|
|
}
|
|
|
|
error_page 503 @maintenance;
|
|
|
|
location @maintenance {
|
|
rewrite ^(.*)$ /maintenance.html break;
|
|
}
|
|
|
|
location = /maintenance.html {
|
|
internal;
|
|
}
|
|
|
|
location / {
|
|
proxy_pass http://127.0.0.1:8082;
|
|
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;
|
|
}
|
|
}
|
|
```
|
|
|
|
### 3. Recharger nginx
|
|
|
|
```bash
|
|
sudo nginx -t && sudo systemctl reload nginx
|
|
```
|
|
|
|
---
|
|
|
|
## Fonctionnement
|
|
|
|
```
|
|
Central (container)
|
|
└── touch /var/www/maintenance/lesstime/maintenance.on
|
|
│ (volume Docker : /var/www/lesstime → /var/www/maintenance/lesstime)
|
|
▼
|
|
/var/www/lesstime/maintenance.on (hote)
|
|
│
|
|
▼
|
|
nginx hote : if (-f /var/www/lesstime/maintenance.on) → 503
|
|
│
|
|
▼
|
|
maintenance.html servie depuis /var/www/lesstime/public/
|
|
```
|