From d17754efabe1c22fd48a94fe888577f4ed603e98 Mon Sep 17 00:00:00 2001 From: dev-qwen2 Date: Mon, 20 Apr 2026 15:09:34 +0000 Subject: [PATCH] fix: fix: strip /staging prefix in Caddyfile before proxying to staging container (#1079) --- lib/generators.sh | 1 + nomad/jobs/edge.hcl | 1 + tests/test-caddyfile-routing.sh | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/lib/generators.sh b/lib/generators.sh index 739ca50..aa8c373 100644 --- a/lib/generators.sh +++ b/lib/generators.sh @@ -860,6 +860,7 @@ _generate_caddyfile_subpath() { # Reverse proxy to staging handle /staging/* { + uri strip_prefix /staging reverse_proxy staging:80 } diff --git a/nomad/jobs/edge.hcl b/nomad/jobs/edge.hcl index afc57c3..67c474c 100644 --- a/nomad/jobs/edge.hcl +++ b/nomad/jobs/edge.hcl @@ -161,6 +161,7 @@ EOT # Reverse proxy to staging — dynamic port via Nomad service discovery handle /staging/* { + uri strip_prefix /staging {{ range nomadService "staging" }} reverse_proxy {{ .Address }}:{{ .Port }} {{ end }} } diff --git a/tests/test-caddyfile-routing.sh b/tests/test-caddyfile-routing.sh index 52a7a3d..7eea806 100755 --- a/tests/test-caddyfile-routing.sh +++ b/tests/test-caddyfile-routing.sh @@ -125,6 +125,13 @@ check_staging_routing() { tr_fail "Missing Staging handle block (handle /staging/*)" fi + # Check for uri strip_prefix /staging directive + if echo "$CADDYFILE" | grep -q "uri strip_prefix /staging"; then + tr_pass "Staging uri strip_prefix configured (/staging)" + else + tr_fail "Missing uri strip_prefix /staging for staging" + fi + # Check for nomadService discovery (dynamic port) if echo "$CADDYFILE" | grep -q "nomadService"; then tr_pass "Staging uses Nomad service discovery"