fix: strip /staging prefix in Caddyfile before proxying to staging container #1079

Closed
opened 2026-04-20 15:08:25 +00:00 by disinto-admin · 0 comments

Goal

Caddyfile routing for /staging/* currently proxies the full path to the staging container, which serves static files from /srv/site without a /staging/ subdir — results in 404. Strip the /staging prefix before proxying so the static server sees / (or /index.html, /assets/…) instead of /staging/….

Evidence

Live probe on 2026-04-20 after docker compose up -d --build edge on disinto-dev-box:

$ curl -sI http://localhost/staging/
HTTP/1.1 404 Not Found
Server: Caddy
Via: 1.1 Caddy

Caddyfile block (/home/johba/disinto/docker/Caddyfile, and lib/generators.sh:862):

handle /staging/* {
    reverse_proxy staging:80
}

Staging container is a Caddy file-server --root /srv/site. Forwarding /staging/index.html → staging:80/staging/index.html, which doesn't exist → 404.

The fix

Add uri strip_prefix /staging before reverse_proxy:

handle /staging/* {
    uri strip_prefix /staging
    reverse_proxy staging:80
}

This rewrites /staging/index.html/index.html before the proxy call, which the staging file-server resolves correctly.

Apply the edit in lib/generators.sh:862 (the generator is canonical source — the tracked docker/Caddyfile gets overwritten on next disinto init). Do not hand-edit docker/Caddyfile directly.

Acceptance criteria

  • lib/generators.sh emits uri strip_prefix /staging inside the handle /staging/* block
  • docker/Caddyfile.template (if present) updated to match
  • After regenerating the Caddyfile and restarting edge: curl http://localhost/staging/ returns 200 (the staging index) instead of 404
  • Requests for nested paths (curl http://localhost/staging/assets/foo.css) reach the staging container with the stripped path and return appropriate status
  • tests/test-caddyfile-routing.sh and/or tests/smoke-edge-subpath.sh assertions pass for the staging path after the fix
  • shellcheck clean on lib/generators.sh

Affected files

  • lib/generators.sh — add uri strip_prefix /staging in the staging handle block
  • tests/test-caddyfile-routing.sh — update assertion to check for the strip_prefix directive (optional)
  • .woodpecker/edge-subpath.yml — no change expected; caddy-validate should accept the new directive
  • Vision #623 — edge subpath routing
  • #1025 — smoke-test tool which surfaced this gap (merged)
  • Same fix pattern may apply to /forge/* (tracked in separate issue)
## Goal Caddyfile routing for `/staging/*` currently proxies the full path to the staging container, which serves static files from `/srv/site` without a `/staging/` subdir — results in 404. Strip the `/staging` prefix before proxying so the static server sees `/` (or `/index.html`, `/assets/…`) instead of `/staging/…`. ## Evidence Live probe on 2026-04-20 after `docker compose up -d --build edge` on disinto-dev-box: ``` $ curl -sI http://localhost/staging/ HTTP/1.1 404 Not Found Server: Caddy Via: 1.1 Caddy ``` Caddyfile block (`/home/johba/disinto/docker/Caddyfile`, and `lib/generators.sh:862`): ``` handle /staging/* { reverse_proxy staging:80 } ``` Staging container is a Caddy `file-server --root /srv/site`. Forwarding `/staging/index.html` → staging:80/staging/index.html, which doesn't exist → 404. ## The fix Add `uri strip_prefix /staging` before `reverse_proxy`: ``` handle /staging/* { uri strip_prefix /staging reverse_proxy staging:80 } ``` This rewrites `/staging/index.html` → `/index.html` before the proxy call, which the staging file-server resolves correctly. Apply the edit in **`lib/generators.sh:862`** (the generator is canonical source — the tracked `docker/Caddyfile` gets overwritten on next `disinto init`). Do not hand-edit `docker/Caddyfile` directly. ## Acceptance criteria - [ ] `lib/generators.sh` emits `uri strip_prefix /staging` inside the `handle /staging/*` block - [ ] `docker/Caddyfile.template` (if present) updated to match - [ ] After regenerating the Caddyfile and restarting edge: `curl http://localhost/staging/` returns 200 (the staging index) instead of 404 - [ ] Requests for nested paths (`curl http://localhost/staging/assets/foo.css`) reach the staging container with the stripped path and return appropriate status - [ ] `tests/test-caddyfile-routing.sh` and/or `tests/smoke-edge-subpath.sh` assertions pass for the staging path after the fix - [ ] `shellcheck` clean on `lib/generators.sh` ## Affected files - `lib/generators.sh` — add `uri strip_prefix /staging` in the staging handle block - `tests/test-caddyfile-routing.sh` — update assertion to check for the strip_prefix directive (optional) - `.woodpecker/edge-subpath.yml` — no change expected; caddy-validate should accept the new directive ## Related - Vision #623 — edge subpath routing - #1025 — smoke-test tool which surfaced this gap (merged) - Same fix pattern may apply to `/forge/*` (tracked in separate issue)
disinto-admin added the
backlog
label 2026-04-20 15:08:25 +00:00
dev-qwen2 self-assigned this 2026-04-20 15:08:37 +00:00
dev-qwen2 added
in-progress
and removed
backlog
labels 2026-04-20 15:08:37 +00:00
dev-qwen2 removed their assignment 2026-04-20 15:22:29 +00:00
dev-qwen2 removed the
in-progress
label 2026-04-20 15:22:29 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#1079
No description provided.