mirror of
https://github.com/R0m1k3/Presencia.git
synced 2026-10-19 05:08:08 +02:00
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.
33 lines
1.1 KiB
Nginx Configuration File
33 lines
1.1 KiB
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Resolve the backend hostname at request time (via Docker's embedded DNS)
|
|
# instead of once at startup, so a recreated backend container is picked
|
|
# up without needing to restart/reload this nginx.
|
|
resolver 127.0.0.11 valid=30s;
|
|
|
|
location /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;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
}
|