123 lines
4.8 KiB
Markdown
123 lines
4.8 KiB
Markdown
# Déploiement dev4.4nkweb.com
|
|
|
|
- Nginx: vhost dev4.4nkweb.com HTTP et HTTPS, reverse proxy:
|
|
- /signer vers 3001
|
|
- / vers ihm_client sur 3003
|
|
- /lecoffre vers lecoffre-front sur 3000
|
|
- /back vers lecoffre-back sur 8080
|
|
- /blindbit vers blindbit sur 8000
|
|
- /storage vers sdk_storage sur 8081
|
|
- /ws WebSocket relay
|
|
- Certificats: Lets Encrypt
|
|
- Next.js: basePath /lecoffre, build production, NODE_OPTIONS max-old-space-size 2048
|
|
- Extraits .env pertinents:
|
|
- RELAY_URLS wss://dev4.4nkweb.com/ws
|
|
- SIGNER_WS_URL ws://dev4.4nkweb.com/signer/
|
|
- VITE_BOOTSTRAPURL ws://dev4.4nkweb.com/ws
|
|
- Correction 502: build Next terminé, Nginx OK
|
|
|
|
## Redirection locale depuis local.4nkweb.com:3000
|
|
|
|
Objectif: lorsque l'utilisateur accède à `http://local.4nkweb.com:3000/...`, répondre par une redirection HTTP vers `https://dev4.4nkweb.com/lecoffre/...` sans modifier l'image Docker du front.
|
|
|
|
- Mapping Docker: `lecoffre-front` publié sur `127.0.0.2:3000` (même port, IP loopback dédiée)
|
|
- Fichier: `docker-compose.yml`
|
|
- Ligne modifiée: section `lecoffre-front.ports` → `- "127.0.0.2:3000:3000"`
|
|
- Nginx (hôte):
|
|
- Proxy vers `127.0.0.2:3000` pour `/lecoffre/` et assets `_next`
|
|
- Fichier: `conf/nginx/dev4.4nkweb.com.conf`
|
|
- Lignes modifiées: `proxy_pass http://127.0.0.2:3000/...`
|
|
- Nouveau vhost de redirection pour `local.4nkweb.com` en écoute sur `127.0.0.1:3000`
|
|
- Fichier: `conf/nginx/local.4nkweb.com-3000.conf`
|
|
- Contenu: `return 301 https://dev4.4nkweb.com/lecoffre$request_uri;`
|
|
|
|
Séquence d'application:
|
|
1. Tester la conf Nginx: `sudo nginx -t`
|
|
2. Recharger Nginx: `sudo systemctl reload nginx`
|
|
3. Redéployer le service front: `docker compose up -d lecoffre-front`
|
|
4. Vérifier:
|
|
- `curl -I http://local.4nkweb.com:3000/` → `301` Location `https://dev4.4nkweb.com/lecoffre/`
|
|
- `curl -I http://local.4nkweb.com:3000/authorized-client?code=...` → `301` Location `https://dev4.4nkweb.com/lecoffre/authorized-client?code=...`
|
|
|
|
Rollback simple:
|
|
1. Revenir au mapping initial du front: `ports: ["3000:3000"]`
|
|
2. Dans `conf/nginx/dev4.4nkweb.com.conf`, restaurer les `proxy_pass` sur `127.0.0.1:3000`
|
|
3. Supprimer (ou commenter) `conf/nginx/local.4nkweb.com-3000.conf`
|
|
4. `sudo nginx -t && sudo systemctl reload nginx`
|
|
5. `docker compose up -d lecoffre-front`
|
|
|
|
## Résolution du problème DNS côté client
|
|
|
|
**Problème** : Si vous obtenez `ERR_CONNECTION_REFUSED` dans votre navigateur, c'est que `local.4nkweb.com` résout vers `127.0.0.1` sur votre machine locale au lieu de pointer vers le serveur.
|
|
|
|
**Solution** : Modifiez votre fichier hosts local pour que `local.4nkweb.com` pointe vers l'IP du serveur (`92.243.24.12`).
|
|
|
|
### Sur Windows
|
|
Ajoutez dans `C:\Windows\System32\drivers\etc\hosts` :
|
|
```
|
|
92.243.24.12 local.4nkweb.com
|
|
```
|
|
|
|
Puis videz le cache DNS :
|
|
```cmd
|
|
ipconfig /flushdns
|
|
```
|
|
|
|
### Sur Linux
|
|
Ajoutez dans `/etc/hosts` :
|
|
```
|
|
92.243.24.12 local.4nkweb.com
|
|
```
|
|
|
|
Puis redémarrez le service DNS :
|
|
```bash
|
|
sudo systemctl restart systemd-resolved
|
|
```
|
|
|
|
### Sur Mac
|
|
Ajoutez dans `/etc/hosts` :
|
|
```
|
|
92.243.24.12 local.4nkweb.com
|
|
```
|
|
|
|
Puis videz le cache DNS :
|
|
```bash
|
|
sudo dscacheutil -flushcache
|
|
```
|
|
|
|
Après ces modifications, `http://local.4nkweb.com:3000/authorized-client?code=...` devrait rediriger correctement vers `https://dev4.4nkweb.com/lecoffre/authorized-client?code=...`.
|
|
|
|
## Pilotage Nginx depuis le dépôt
|
|
|
|
- Conf actives sur le système pointent vers les fichiers du dépôt:
|
|
- `/etc/nginx/conf.d/ssl-dev4.4nkweb.com.conf` → lien vers `conf/nginx/dev4.4nkweb.com-https.conf`
|
|
- `/etc/nginx/conf.d/local.4nkweb.com-3000.conf` → lien vers `conf/nginx/local.4nkweb.com-3000.conf`
|
|
- Doublon supprimé: `/etc/nginx/sites-enabled/dev4.4nkweb.com.conf`.
|
|
- Vérification et rechargement:
|
|
- `sudo nginx -t`
|
|
- `sudo nginx -s reload`
|
|
|
|
## Variables .env critiques pour le front Next.js
|
|
|
|
Ces variables doivent être sans quotes et sans espaces autour de `=` et alignées sur le sous-chemin `/lecoffre`:
|
|
|
|
- `NEXT_PUBLIC_ANK_BASE_REDIRECT_URI=https://dev4.4nkweb.com/lecoffre/authorized-client`
|
|
- `NEXT_PUBLIC_TARGET_ORIGIN=https://dev4.4nkweb.com/lecoffre`
|
|
|
|
Notes:
|
|
- Les variables `NEXT_PUBLIC_*` sont prises en compte au build; un rebuild est nécessaire après modification.
|
|
|
|
## Rebuild de lecoffre-front avec le .env courant
|
|
|
|
Étapes:
|
|
1. Vérifier que le conteneur contient le code:
|
|
- `sudo docker exec -i lecoffre-front sh -lc "test -f package.json && echo ok || echo ko"`
|
|
2. Lancer le build (mémoire augmentée):
|
|
- `sudo docker exec -i lecoffre-front sh -lc "export NODE_OPTIONS=--max-old-space-size=2048; npm run build"`
|
|
3. Redémarrer le service:
|
|
- `sudo docker compose -f docker-compose.yml restart lecoffre-front`
|
|
4. Tester:
|
|
- `curl -si https://dev4.4nkweb.com/lecoffre/`
|
|
|
|
Incident connu: 500 SSR « Invalid targetOrigin » résolu en corrigeant `NEXT_PUBLIC_TARGET_ORIGIN` puis rebuild.
|