From 4e602da15d033cbd11248b18e5ad49a8369af93c Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Thu, 12 Feb 2026 23:34:33 +0100 Subject: [PATCH] fix(infra): definitive fix for Traefik Host rule and Gatekeeper bypass - Switched Traefik Host rules from backticks to double quotes for safety. - Used printf in deploy.yml to guarantee literal writing of environment variables. - Verified that Host rules now correctly match without shell-side side-effects. - Maintained WOFF fonts for Satori compatibility. --- .gitea/workflows/deploy.yml | 6 +++--- docker-compose.yml | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 86f060b1..de16b8a6 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -85,10 +85,10 @@ jobs: # Standardize Traefik Rule if [[ "$TRAEFIK_HOST" == *","* ]]; then - TRAEFIK_RULE=$(echo "$TRAEFIK_HOST" | sed 's/,/ /g' | awk '{for(i=1;i<=NF;i++) printf "Host(`%s`)%s", $i, (i==NF?"":" || ")}') + TRAEFIK_RULE=$(echo "$TRAEFIK_HOST" | sed 's/,/ /g' | awk '{for(i=1;i<=NF;i++) printf "Host(\"%s\")%s", $i, (i==NF?"":" || ")}') PRIMARY_HOST=$(echo "$TRAEFIK_HOST" | cut -d',' -f1 | sed 's/ //g') else - TRAEFIK_RULE="Host(\`$TRAEFIK_HOST\`)" + TRAEFIK_RULE="Host(\"$TRAEFIK_HOST\")" PRIMARY_HOST="$TRAEFIK_HOST" fi @@ -323,7 +323,7 @@ jobs: echo "TARGET=$TARGET" echo "SENTRY_ENVIRONMENT=$TARGET" echo "PROJECT_NAME=$PROJECT_NAME" - echo "TRAEFIK_HOST_RULE=$TRAEFIK_RULE" + printf 'TRAEFIK_HOST_RULE=%s\n' "$TRAEFIK_RULE" echo "TRAEFIK_HOST=$TRAEFIK_HOST" echo "ENV_FILE=$ENV_FILE" echo "COMPOSE_PROFILES=$COMPOSE_PROFILES" diff --git a/docker-compose.yml b/docker-compose.yml index 4ddb7a5a..260f1d41 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,11 +10,11 @@ services: labels: - "traefik.enable=true" # HTTP ⇒ HTTPS redirect - - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-web.rule=${TRAEFIK_HOST_RULE:-Host(`klz-cables.com`)}" + - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-web.rule=${TRAEFIK_HOST_RULE:-Host(\"klz-cables.com\")}" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-web.entrypoints=web" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-web.middlewares=redirect-https" # HTTPS router (Standard) - - "traefik.http.routers.${PROJECT_NAME:-klz-cables}.rule=${TRAEFIK_HOST_RULE:-Host(`klz-cables.com`)}" + - "traefik.http.routers.${PROJECT_NAME:-klz-cables}.rule=${TRAEFIK_HOST_RULE:-Host(\"klz-cables.com\")}" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}.entrypoints=websecure" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}.tls.certresolver=le" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}.tls=true" @@ -22,7 +22,7 @@ services: - "traefik.http.routers.${PROJECT_NAME:-klz-cables}.middlewares=${AUTH_MIDDLEWARE:-${PROJECT_NAME:-klz-cables}-ratelimit,${PROJECT_NAME:-klz-cables}-forward,${PROJECT_NAME:-klz-cables}-compress}" # Public Router (Whitelist for OG Images, Sitemaps, Health) - - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-public.rule=(${TRAEFIK_HOST_RULE:-Host(`klz-cables.com`)}) && (PathPrefix(`/health`, `/sitemap.xml`, `/robots.txt`, `/manifest.webmanifest`, `/api/og`) || PathPrefix(`/de/opengraph-image`, `/en/opengraph-image`, `/de/blog/opengraph-image`, `/en/blog/opengraph-image`, `/de/products/opengraph-image`, `/en/products/opengraph-image`) || PathRegexp(`^/.*opengraph-image.*$`))" + - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-public.rule=(${TRAEFIK_HOST_RULE:-Host(\"klz-cables.com\")}) && (PathPrefix(\"/health\", \"/sitemap.xml\", \"/robots.txt\", \"/manifest.webmanifest\", \"/api/og\") || PathPrefix(\"/de/opengraph-image\", \"/en/opengraph-image\", \"/de/blog/opengraph-image\", \"/en/blog/opengraph-image\", \"/de/products/opengraph-image\", \"/en/products/opengraph-image\") || PathRegexp(\"^/.*opengraph-image.*$\"))" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-public.entrypoints=websecure" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-public.tls.certresolver=le" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-public.tls=true" @@ -78,7 +78,7 @@ services: labels: - "traefik.enable=true" - "traefik.docker.network=infra" - - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.rule=(Host(`${TRAEFIK_HOST:-testing.klz-cables.com}`) && PathPrefix(`/gatekeeper`))" + - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.rule=(Host(\"${TRAEFIK_HOST:-testing.klz-cables.com}\") && PathPrefix(\"/gatekeeper\"))" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.entrypoints=websecure" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.tls.certresolver=le" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-gatekeeper.tls=true" @@ -120,7 +120,7 @@ services: - ./directus/migrations:/directus/migrations labels: - "traefik.enable=true" - - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-directus.rule=Host(`${DIRECTUS_HOST}`)" + - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-directus.rule=Host(\"${DIRECTUS_HOST}\")" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-directus.entrypoints=websecure" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-directus.tls.certresolver=le" - "traefik.http.routers.${PROJECT_NAME:-klz-cables}-directus.tls=true"