From 1fcc6b05be0fefbe21d4e6f205897b4f366819e6 Mon Sep 17 00:00:00 2001 From: TheThomaas Date: Tue, 8 Sep 2026 12:43:11 +0000 Subject: [PATCH] Ajouter cookcli/rootfs/etc/cont-init.d/99-nginx-config.sh --- .../rootfs/etc/cont-init.d/99-nginx-config.sh | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 cookcli/rootfs/etc/cont-init.d/99-nginx-config.sh diff --git a/cookcli/rootfs/etc/cont-init.d/99-nginx-config.sh b/cookcli/rootfs/etc/cont-init.d/99-nginx-config.sh new file mode 100644 index 0000000..06e4ed4 --- /dev/null +++ b/cookcli/rootfs/etc/cont-init.d/99-nginx-config.sh @@ -0,0 +1,67 @@ +#!/usr/bin/with-contenv bashio +set -e + +bashio::log.info "=== Génération de la configuration Nginx ===" + +INGRESS_PATH=$(bashio::addon.ingress_entry) +bashio::log.info "=== ${INGRESS_PATH} ===" + +bashio::log.info "Chemin Ingress: ${INGRESS_PATH}" + +# Générer la configuration complète avec la valeur injectée +cat > /etc/nginx/nginx.conf << EOF +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + sendfile on; + keepalive_timeout 65; + + access_log /proc/1/fd/1; + error_log /proc/1/fd/2; + + server { + listen 9080; + allow 172.30.32.2; + deny all; + + server_name localhost; + + client_max_body_size 10M; + + # Headers de base + 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 simple 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; + + sub_filter_once off; + sub_filter_types text/css application/javascript; + sub_filter 'href="/' 'href="${INGRESS_PATH}/'; + sub_filter 'src="/' 'src="${INGRESS_PATH}/'; + sub_filter 'action="/' 'action="${INGRESS_PATH}/'; + + # Gérer les redirections + proxy_redirect http://127.0.0.1:9081/ \$scheme://$host${INGRESS_PATH}/; + proxy_redirect http://127.0.0.1:9081 \$scheme://$host${INGRESS_PATH}; + } + } +} + +EOF + +bashio::log.info "✅ Configuration Nginx générée avec succès" \ No newline at end of file