diff --git a/cookcli/rootfs/etc/nginx/nginx.conf b/cookcli/rootfs/etc/nginx/nginx.conf index 1442175..be73cf0 100644 --- a/cookcli/rootfs/etc/nginx/nginx.conf +++ b/cookcli/rootfs/etc/nginx/nginx.conf @@ -24,15 +24,49 @@ http { 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; + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Port $server_port; - # Proxy simple vers CookCLI + # Désactiver le buffering + proxy_buffering off; + + # Proxy vers CookCLI location / { proxy_pass http://127.0.0.1:9081; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; - proxy_buffering off; + + # --- RÉÉCRITURE DES URLs POUR L'INGRESS --- + # Capture le chemin Ingress depuis les headers + set $ingress_path $http_x_forwarded_prefix; + if ($ingress_path = "") { + set $ingress_path ""; + } + + # Sub_filter pour réécrire les URLs absolues + sub_filter_once off; + sub_filter_types text/html text/css application/javascript; + + # Réécriture des URLs de base + sub_filter 'href="/' 'href="$ingress_path/'; + sub_filter 'src="/' 'src="$ingress_path/'; + sub_filter 'action="/' 'action="$ingress_path/'; + + # Réécriture spécifique pour les chemins courants + sub_filter '"/static/' '"$ingress_path/static/'; + sub_filter '"/assets/' '"$ingress_path/assets/'; + sub_filter '"/css/' '"$ingress_path/css/'; + sub_filter '"/js/' '"$ingress_path/js/'; + + # Si l'application utilise des chemins relatifs, les forcer + sub_filter '