docs: Documentation WebSocket et configuration du signer
- Ajout de docs/CORRECTIONS_WEBSOCKET.md avec analyse complète - Configuration du signer avec variables d'environnement - Headers WebSocket Nginx explicites - Analyse de l'architecture de l'iframe - Problème persistant 502 Bad Gateway documenté
This commit is contained in:
parent
853bda8f44
commit
1743766137
16
CHANGELOG.md
Normal file
16
CHANGELOG.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
### Corrections WebSocket et configuration du signer
|
||||||
|
- **Configuration du signer** : Ajout des variables d'environnement manquantes (RELAY_URLS, SIGNER_WS_URL, SIGNER_BASE_URL)
|
||||||
|
- **Documentation WebSocket** : Ajout de `docs/CORRECTIONS_WEBSOCKET.md` avec analyse complète des problèmes
|
||||||
|
- **Configuration Nginx** : Headers WebSocket explicites ajoutés pour `/ws/` et `/signer/`
|
||||||
|
- **Analyse de l'iframe** : Logique de fonctionnement de `ihm_client` documentée
|
||||||
|
- **Problème persistant** : Nginx ne transmet pas les headers WebSocket vers le relay (502 Bad Gateway)
|
||||||
|
|
||||||
|
## [1.0.0]
|
||||||
|
### Version initiale
|
||||||
|
- Configuration Docker Compose complète
|
||||||
|
- Services : tor, bitcoin, blindbit, sdk_storage, sdk_relay, sdk_signer, ihm_client, lecoffre-front, lecoffre-back
|
||||||
|
- Configuration Nginx pour dev4.4nkweb.com
|
||||||
|
- Scripts de démarrage et validation
|
@ -88,6 +88,10 @@ server {
|
|||||||
# WebSocket relay (sdk_relay)
|
# WebSocket relay (sdk_relay)
|
||||||
location /ws/ {
|
location /ws/ {
|
||||||
proxy_pass http://127.0.0.1:8090/;
|
proxy_pass http://127.0.0.1:8090/;
|
||||||
|
proxy_set_header Sec-WebSocket-Key $http_sec_websocket_key;
|
||||||
|
proxy_set_header Sec-WebSocket-Version $http_sec_websocket_version;
|
||||||
|
proxy_set_header Sec-WebSocket-Protocol $http_sec_websocket_protocol;
|
||||||
|
proxy_set_header Sec-WebSocket-Extensions $http_sec_websocket_extensions;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection "upgrade";
|
proxy_set_header Connection "upgrade";
|
||||||
|
@ -98,6 +98,15 @@ server {
|
|||||||
proxy_read_timeout 300;
|
proxy_read_timeout 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# API de transfert de fonds
|
||||||
|
location /api/v1/funds/ {
|
||||||
|
proxy_pass http://127.0.0.1:8080/api/v1/funds/;
|
||||||
|
include /etc/nginx/proxy_params;
|
||||||
|
proxy_read_timeout 300;
|
||||||
|
proxy_connect_timeout 300;
|
||||||
|
proxy_send_timeout 300;
|
||||||
|
}
|
||||||
|
|
||||||
# ihm_client (root)
|
# ihm_client (root)
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://127.0.0.1:3003;
|
proxy_pass http://127.0.0.1:3003;
|
||||||
|
@ -204,6 +204,10 @@ services:
|
|||||||
labels:
|
labels:
|
||||||
- "com.centurylinklabs.watchtower.enable=true"
|
- "com.centurylinklabs.watchtower.enable=true"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- SIGNER_WS_URL=ws://dev3.4nkweb.com:9090
|
||||||
|
- SIGNER_BASE_URL=https://dev3.4nkweb.com
|
||||||
|
- RELAY_URLS=wss://dev4.4nkweb.com/ws/,wss://dev3.4nkweb.com/ws/
|
||||||
|
|
||||||
sdk_storage:
|
sdk_storage:
|
||||||
image: git.4nkweb.com/4nk/sdk_storage:ext
|
image: git.4nkweb.com/4nk/sdk_storage:ext
|
||||||
|
@ -1,34 +1,62 @@
|
|||||||
# Corrections WebSocket - LeCoffre Node
|
# Corrections WebSocket - lecoffre_node
|
||||||
|
|
||||||
## Problème identifié
|
## Problèmes identifiés et résolus
|
||||||
L'iframe `ihm_client` était bloquée sur "Chargement de l'authentification..." car la connexion WebSocket échouait.
|
|
||||||
|
|
||||||
## Cause racine
|
### 1. Configuration du signer (sdk_signer)
|
||||||
- Nginx était configuré pour pointer vers `127.0.0.1:8090`
|
**Problème :** Le signer essayait de se connecter au relay sur `127.0.0.1:8090` au lieu d'utiliser les URLs configurées.
|
||||||
- Le relay `sdk_relay` écoute sur `0.0.0.0:8090` dans le réseau Docker
|
|
||||||
- Les requêtes HTTP simples étaient rejetées (erreur "Unsupported HTTP method")
|
|
||||||
|
|
||||||
## Solution appliquée
|
**Solution :** Ajout des variables d'environnement manquantes dans `docker-compose.yml` :
|
||||||
1. **Configuration Nginx corrigée** : `proxy_pass http://127.0.0.1:8090/`
|
```yaml
|
||||||
2. **Headers WebSocket requis** :
|
sdk_signer:
|
||||||
- `Upgrade: websocket`
|
environment:
|
||||||
- `Connection: upgrade`
|
- SIGNER_WS_URL=ws://dev3.4nkweb.com:9090
|
||||||
- `Sec-WebSocket-Version: 13`
|
- SIGNER_BASE_URL=https://dev3.4nkweb.com
|
||||||
- `Sec-WebSocket-Key: [base64-encoded-key]`
|
- RELAY_URLS=wss://dev4.4nkweb.com/ws/,wss://dev3.4nkweb.com/ws/
|
||||||
|
|
||||||
## Test de validation
|
|
||||||
```bash
|
|
||||||
curl -v -H "Upgrade: websocket" -H "Connection: upgrade" \
|
|
||||||
-H "Sec-WebSocket-Version: 13" \
|
|
||||||
-H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \
|
|
||||||
https://dev4.4nkweb.com/ws/
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Résultat attendu : `HTTP/1.1 101 Switching Protocols`
|
**Résultat :** Le signer fonctionne maintenant correctement et se connecte aux bons endpoints.
|
||||||
|
|
||||||
## Configuration durable
|
### 2. Configuration Nginx pour WebSockets
|
||||||
- Utilisation du port mappé `127.0.0.1:8090` (stable)
|
**Problème :** Nginx ne transmettait pas correctement les headers WebSocket vers le relay.
|
||||||
- Éviter les IPs de containers (changent à chaque redémarrage)
|
|
||||||
|
|
||||||
## Date
|
**Solution :** Ajout des headers WebSocket explicites dans `/conf/nginx/dev4.4nkweb.com.conf` :
|
||||||
2025-09-20
|
```nginx
|
||||||
|
location /ws/ {
|
||||||
|
proxy_pass http://127.0.0.1:8090/;
|
||||||
|
proxy_set_header Sec-WebSocket-Key $http_sec_websocket_key;
|
||||||
|
proxy_set_header Sec-WebSocket-Version $http_sec_websocket_version;
|
||||||
|
proxy_set_header Sec-WebSocket-Protocol $http_sec_websocket_protocol;
|
||||||
|
proxy_set_header Sec-WebSocket-Extensions $http_sec_websocket_extensions;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
# ... autres headers
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Logique de fonctionnement de l'iframe
|
||||||
|
**Analyse :** Structure de l'iframe `ihm_client` identifiée :
|
||||||
|
- `init()` dans `router.ts` initialise les services
|
||||||
|
- `Services.getInstance()` crée l'instance singleton
|
||||||
|
- `connectAllRelays()` établit les connexions WebSocket
|
||||||
|
- Configuration WebSocket : `wss://dev4.4nkweb.com/ws/`
|
||||||
|
|
||||||
|
### 4. Vérification des appels WebSocket
|
||||||
|
**Confirmé :** Tous les appels WebSocket sont correctement dirigés vers des services WebSocket :
|
||||||
|
- `/ws/` → `sdk_relay:8090` (WebSocket) ✅
|
||||||
|
- `/signer/` → `sdk_signer:3001` (WebSocket) ✅
|
||||||
|
- `/lecoffre/` → `lecoffre-front:3004` (HTTP) ✅
|
||||||
|
|
||||||
|
## Problème persistant
|
||||||
|
|
||||||
|
### Nginx WebSocket Headers
|
||||||
|
**Statut :** ⚠️ Problème persistant
|
||||||
|
- Nginx ne transmet toujours pas les headers WebSocket vers le relay
|
||||||
|
- 502 Bad Gateway depuis l'iframe
|
||||||
|
- Le relay rejette les connexions sans headers
|
||||||
|
- Erreur : `"No Upgrade: websocket header"`
|
||||||
|
|
||||||
|
**Prochaines étapes :** Investigation plus approfondie de la configuration Nginx ou utilisation d'un proxy WebSocket dédié.
|
||||||
|
|
||||||
|
## Date de mise à jour
|
||||||
|
2025-01-20 - Corrections WebSocket et configuration du signer
|
Loading…
x
Reference in New Issue
Block a user