From 441a1758a5dec0a85db8881939774cbc5a9c9f70 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 6 Jul 2026 14:49:23 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20la=20r=C3=A9solution=20DNS=20dynamique?= =?UTF-8?q?=20du=20nginx=20frontend=20=C3=A9crasait=20le=20chemin=20de=20l?= =?UTF-8?q?'API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avec un proxy_pass entièrement basé sur une variable, nginx ne remplace plus le préfixe de location par le reste de l'URI comme il le fait pour une valeur statique : toutes les requêtes /api/* étaient réécrites en exactement /api/ (sans /auth/login, /users, etc.), d'où les 404 sur toutes les routes. Fix : $request_uri est maintenant explicitement ajouté au proxy_pass pour transmettre le chemin et la query string d'origine. Reproduit et vérifié avec un vrai nginx local + un faux backend qui échoue le chemin reçu : le bug était bien présent avec l'ancienne config, et absent avec la nouvelle. --- frontend/nginx.conf | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 504c797..0783a06 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -11,8 +11,14 @@ server { resolver 127.0.0.11 valid=30s; location /api/ { - set $backend_upstream http://presencia-backend:4790; - proxy_pass $backend_upstream/api/; + set $backend_upstream presencia-backend; + # $request_uri (the raw, un-normalized original URI) must be appended + # explicitly: when the proxy_pass target is built from a variable, + # nginx does NOT replace the matched location prefix with the rest of + # the request URI like it does for a static proxy_pass value — it + # would otherwise always forward the literal "/api/" with nothing + # appended, regardless of the actual path requested. + proxy_pass http://$backend_upstream:4790$request_uri; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;