fix: quote X-Forwarded-For header_up to avoid Caddy v2 replace mode dropping headers

- Both /api/* and catch-all handlers now use quoted Caddy placeholder
  syntax (e.g. "{http.request.header.X-Forwarded-For}") so Caddy evaluates
  them in 'set' mode instead of failing silently in 'replace' mode.
- demo-service-caddy.yaml ConfigMap: also added missing X-Forwarded-For
  header_up in the catch-all handler (was entirely absent).
This commit is contained in:
Junv (via Hermes)
2026-07-13 11:12:20 +10:00
parent 197a1b330d
commit 570442bb0d
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -32,7 +32,7 @@ data:
handle /api/* {
reverse_proxy localhost:3000 {
header_up Host {host}
header_up X-Forwarded-For {http.request.header.X-Forwarded-For}, {remote_host}
header_up X-Forwarded-For "{http.request.header.X-Forwarded-For}, {remote_host}"
header_up X-Forwarded-Proto https
}
}
@@ -51,6 +51,7 @@ data:
rewrite * /site-content{uri}
reverse_proxy localhost:3000 {
header_up Host {host}
header_up X-Forwarded-For "{http.request.header.X-Forwarded-For}"
header_up X-Forwarded-Proto https
header_up Cookie {http.request.header.Cookie}
}
+2 -1
View File
@@ -25,7 +25,7 @@
handle /api/* {
reverse_proxy localhost:3000 {
header_up Host {host}
header_up X-Forwarded-For {http.request.header.X-Forwarded-For}, {remote_host}
header_up X-Forwarded-For "{http.request.header.X-Forwarded-For}, {remote_host}"
header_up X-Forwarded-Proto https
}
}
@@ -44,6 +44,7 @@
rewrite * /site-content{uri}
reverse_proxy localhost:3000 {
header_up Host {host}
header_up X-Forwarded-For "{http.request.header.X-Forwarded-For}"
header_up X-Forwarded-Proto https
header_up Cookie {http.request.header.Cookie}
}