bug: Caddyfile in edge.hcl has invalid header_up at handle-block top level — Caddy rejects config #1117

Closed
opened 2026-04-21 12:49:00 +00:00 by dev-bot · 1 comment
Collaborator

Symptom

Edge alloc reaches template-render stage but caddy task crashes immediately with:

Error: adapting config using caddyfile: parsing caddyfile tokens for 'handle':
unrecognized directive: header_up - are you sure your Caddyfile structure
(nesting and braces) is correct?, at /etc/caddy/Caddyfile:39

Root cause

nomad/jobs/edge.hcl Caddyfile template around lines 155-165 (in the /chat/ws handler):

# WebSocket endpoint for streaming (#1026)
handle /chat/ws {
    header_up Upgrade $http.upgrade
    header_up Connection $http.connection
    reverse_proxy 127.0.0.1:8080
}

header_up is a sub-directive of reverse_proxy, not a valid directive at the handle block top level. Caddy's Caddyfile parser rejects the file, and the entire edge proxy fails to start.

Same pattern likely valid in prior Caddy versions (header_up was accepted at matcher level in older Caddy 2.x), but the edge image uses caddy:latest which resolves to current major — strictly no.

Reproduction

Fresh box, latest main, after patching bugs #<bug1/2/3>:

disinto init --backend=nomad --with edge --yes
nomad alloc logs -stderr <edge-alloc-id> caddy
# shows the Error above

Fix

Wrap header_up directives inside the reverse_proxy block:

handle /chat/ws {
    reverse_proxy 127.0.0.1:8080 {
        header_up Upgrade {http.request.header.Upgrade}
        header_up Connection {http.request.header.Connection}
    }
}

(Also note: $http.upgrade is wrong syntax — Caddy placeholder is {http.request.header.Upgrade}.)

Acceptance

  • caddy validate passes for the rendered Caddyfile
  • Edge alloc reaches running with caddy listening on :80 and :443
  • curl http://<edge-ip>/forge/api/v1/version returns Forgejo version
## Symptom Edge alloc reaches template-render stage but caddy task crashes immediately with: ``` Error: adapting config using caddyfile: parsing caddyfile tokens for 'handle': unrecognized directive: header_up - are you sure your Caddyfile structure (nesting and braces) is correct?, at /etc/caddy/Caddyfile:39 ``` ## Root cause `nomad/jobs/edge.hcl` Caddyfile template around lines 155-165 (in the `/chat/ws` handler): ```caddy # WebSocket endpoint for streaming (#1026) handle /chat/ws { header_up Upgrade $http.upgrade header_up Connection $http.connection reverse_proxy 127.0.0.1:8080 } ``` `header_up` is a sub-directive of `reverse_proxy`, not a valid directive at the `handle` block top level. Caddy's Caddyfile parser rejects the file, and the entire edge proxy fails to start. Same pattern likely valid in prior Caddy versions (header_up was accepted at matcher level in older Caddy 2.x), but the edge image uses `caddy:latest` which resolves to current major — strictly no. ## Reproduction Fresh box, latest main, after patching bugs #<bug1/2/3>: ```bash disinto init --backend=nomad --with edge --yes nomad alloc logs -stderr <edge-alloc-id> caddy # shows the Error above ``` ## Fix Wrap `header_up` directives inside the `reverse_proxy` block: ```caddy handle /chat/ws { reverse_proxy 127.0.0.1:8080 { header_up Upgrade {http.request.header.Upgrade} header_up Connection {http.request.header.Connection} } } ``` (Also note: `$http.upgrade` is wrong syntax — Caddy placeholder is `{http.request.header.Upgrade}`.) ## Acceptance - `caddy validate` passes for the rendered Caddyfile - Edge alloc reaches `running` with caddy listening on :80 and :443 - `curl http://<edge-ip>/forge/api/v1/version` returns Forgejo version
dev-bot added the
backlog
label 2026-04-21 12:49:00 +00:00
dev-qwen self-assigned this 2026-04-21 14:02:17 +00:00
dev-qwen added
in-progress
and removed
backlog
labels 2026-04-21 14:02:17 +00:00
Collaborator

Blocked — issue #1117

Field Value
Exit reason ci_timeout
Timestamp 2026-04-21T14:35:34Z
### Blocked — issue #1117 | Field | Value | |---|---| | Exit reason | `ci_timeout` | | Timestamp | `2026-04-21T14:35:34Z` |
dev-qwen added
blocked
and removed
in-progress
labels 2026-04-21 14:35:34 +00:00
disinto-admin added
backlog
and removed
blocked
labels 2026-04-21 15:11:30 +00:00
dev-qwen was unassigned by disinto-admin 2026-04-21 15:11:31 +00:00
dev-bot self-assigned this 2026-04-21 16:56:43 +00:00
dev-bot added
in-progress
and removed
backlog
labels 2026-04-21 16:56:43 +00:00
dev-bot removed their assignment 2026-04-21 17:17:28 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: disinto-admin/disinto#1117
No description provided.