edge: port 80 serves the full Forgejo UI in cleartext — no HTTP→HTTPS redirect #64

Closed
opened 2026-07-02 01:31:08 +00:00 by plat · 3 comments
Owner

Found while validating a fresh wb-gate germination (plat.local). curl --resolve git.plat.local:80:127.0.0.1 http://git.plat.local/ → HTTP/1.1 200 with the full Forgejo HTML (login form posts credentials in cleartext); expected 301/308 to https. Traefik ships no redirectscheme middleware / websecure-only entrypoint in gitops. Low risk on a local k3d loopback, real on any host-exposed :80 (HYB single-VPS path exposes traefik behind the tunnel — the tunnel terminates TLS, but a direct-IP :80 hit still lands plaintext). Fix: gitops traefik config — global entrypoint redirection web→websecure (or a router-level redirectscheme middleware), carried to daughters via the next seed refresh.

Found while validating a fresh wb-gate germination (plat.local). `curl --resolve git.plat.local:80:127.0.0.1 http://git.plat.local/` → HTTP/1.1 200 with the full Forgejo HTML (login form posts credentials in cleartext); expected 301/308 to https. Traefik ships no redirectscheme middleware / websecure-only entrypoint in gitops. Low risk on a local k3d loopback, real on any host-exposed :80 (HYB single-VPS path exposes traefik behind the tunnel — the tunnel terminates TLS, but a direct-IP :80 hit still lands plaintext). Fix: gitops traefik config — global entrypoint redirection web→websecure (or a router-level redirectscheme middleware), carried to daughters via the next seed refresh.
Author
Owner

Status: first approach FAILED validation on the live daughter and was reverted there — do not ship. Attaching a redirectScheme middleware at the entrypoint (ports.web.middlewares: [traefik-redirect-to-https@kubernetescrd], middleware via chart extraObjects) makes traefik v3.5 404 EVERY router on the web entrypoint: at boot the Ingress-provider routers build before the CRD provider snapshot merges, each logs middleware …@kubernetescrd does not exist, and the config never converges even after clean restarts. Findings + constraints for the rework: (a) the HYB-1 tunnel forwards plain HTTP into web (http://traefik.kube-system.svc), so a NAIVE entrypoint redirections would loop tunnel traffic unless the tunnel contract moves to an https origin (cloudflared supports noTLSVerify); (b) cloudflared sets X-Forwarded-Proto: https, so a scheme-aware redirect + trusted forwardedHeaders remains the semantics we want IF the middleware can be defined provider-locally (file provider / static config) instead of cross-provider; (c) registry mirror path bypasses traefik (Caddy → forgejo-http:3000) — unaffected either way. Rework in progress on branch fix/web-entrypoint-https-redirect (plat/gitops).

Status: first approach FAILED validation on the live daughter and was reverted there — do not ship. Attaching a `redirectScheme` middleware at the entrypoint (`ports.web.middlewares: [traefik-redirect-to-https@kubernetescrd]`, middleware via chart `extraObjects`) makes traefik v3.5 404 EVERY router on the web entrypoint: at boot the Ingress-provider routers build before the CRD provider snapshot merges, each logs `middleware …@kubernetescrd does not exist`, and the config never converges even after clean restarts. Findings + constraints for the rework: (a) the HYB-1 tunnel forwards plain HTTP into `web` (`http://traefik.kube-system.svc`), so a NAIVE entrypoint `redirections` would loop tunnel traffic unless the tunnel contract moves to an https origin (cloudflared supports noTLSVerify); (b) cloudflared sets `X-Forwarded-Proto: https`, so a scheme-aware redirect + trusted forwardedHeaders remains the semantics we want IF the middleware can be defined provider-locally (file provider / static config) instead of cross-provider; (c) registry mirror path bypasses traefik (Caddy → forgejo-http:3000) — unaffected either way. Rework in progress on branch `fix/web-entrypoint-https-redirect` (plat/gitops).
Author
Owner

Rework shipped: plat/gitops#11 (plat/gitops#11) replaces the failed @kubernetescrd entrypoint-middleware attempt with a file-provider middleware — chart-native providers.file.content renders redirect-to-https into a ConfigMap loaded at boot before any Kubernetes provider syncs, so the entrypoint reference is first-try-safe on a fresh germination (the @kubernetescrd ref raced the CRD provider's first sync and 404'd every Ingress-provider web router, never converging). Validated on the live k3d daughter with the byte-identical change flux-applied to its gitops main: bare http://git.plat.local/ → 301 https://git.plat.local/ (path+query preserved), :443 → 200, in-cluster plain-HTTP with trusted X-Forwarded-Proto: https → 200 with no redirect (HYB-1 tunnel semantics intact via forwardedHeaders.trustedIPs on the pod/service CIDRs), same request without the header → 301, app ingress (pulse) → 200, and every assertion re-passed identically after a rollout restart boot-race check with zero middleware does not exist log lines.

Rework shipped: plat/gitops#11 (https://git.open-platform.sh/plat/gitops/pulls/11) replaces the failed `@kubernetescrd` entrypoint-middleware attempt with a **file-provider** middleware — chart-native `providers.file.content` renders `redirect-to-https` into a ConfigMap loaded at boot before any Kubernetes provider syncs, so the entrypoint reference is first-try-safe on a fresh germination (the `@kubernetescrd` ref raced the CRD provider's first sync and 404'd every Ingress-provider web router, never converging). Validated on the live k3d daughter with the byte-identical change flux-applied to its gitops main: bare `http://git.plat.local/` → `301 https://git.plat.local/` (path+query preserved), `:443` → 200, in-cluster plain-HTTP with trusted `X-Forwarded-Proto: https` → 200 with no redirect (HYB-1 tunnel semantics intact via `forwardedHeaders.trustedIPs` on the pod/service CIDRs), same request without the header → 301, app ingress (pulse) → 200, and every assertion re-passed identically after a `rollout restart` boot-race check with zero `middleware does not exist` log lines.
Author
Owner

Fixed by plat/gitops#11 (file-provider redirectScheme + trusted XFP), merged to gitops main and carried in the genesis seed. Validated on two platforms incl. germinated-first-boot + traefik-restart race checks; the failed entrypoint@kubernetescrd approach is documented above for posterity.

Fixed by plat/gitops#11 (file-provider redirectScheme + trusted XFP), merged to gitops main and carried in the genesis seed. Validated on two platforms incl. germinated-first-boot + traefik-restart race checks; the failed entrypoint@kubernetescrd approach is documented above for posterity.
plat closed this issue 2026-07-02 13:06:30 +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
open-platform/mitosis#64
No description provided.