fix(ingress): let Traefik own HTTP-01 challenge path (#23)

## Problem

Let's Encrypt HTTP-01 requests were reaching ordinary Kubernetes HTTP routes instead of Traefik's internal ACME challenge handler. The CA observed backend responses (404/401/403), so Traefik continued serving its default certificate.

## Change

- remove the Kubernetes `web` catch-all redirect Ingress and its backend routes;
- restore Traefik entrypoint HTTP-to-HTTPS redirect;
- set the redirect port explicitly to public `443`, preventing internal `:8443` in `Location`;
- keep `web` available for the built-in HTTP-01 challenge router;
- update the ingress decision/runbook.

## Verification

- `git diff --check` passes;
- `kubectl kustomize k3s_rencher/infrastructure/ingress` renders successfully;
- rendered resources no longer include the Kubernetes HTTP redirect catch-all;
- the Traefik redirect explicitly targets public port `443`.

## Post-merge acceptance

Verify externally that HTTP redirects to `https://<host>/` without `:8443`, a real HTTP-01 attempt succeeds, and the served certificate has Let's Encrypt issuer/SANs for all four domains.

---------

Co-authored-by: Hermes Agent <hermes@localhost>
Reviewed-on: #23
Reviewed-by: admin <rudolfss13@gmail.com>
Co-authored-by: hermes <rudolfss13+hermes@gmail.com>
This commit was merged in pull request #23.
This commit is contained in:
2026-11-22 22:29:19 +01:00
committed by admin
co-authored by Hermes Agent
parent 0f9c5fa105
commit 0d29c7d7af
5 changed files with 11 additions and 72 deletions
@@ -32,9 +32,9 @@ WAN TCP 443 -> 192.168.1.114:443
Configure a Traefik `websecure` entrypoint on port `443` and use Traefik's
Let's Encrypt ACME resolver with the HTTP-01 challenge on the `web` entrypoint
(port `80`). Ordinary HTTP routes use a separate permanent `redirectScheme`
middleware on `web`; TLS routes are pinned to `websecure`. This keeps the
internal ACME challenge router separate from backend routes. Public Kubernetes
(port `80`). Ordinary HTTP requests use a permanent entrypoint redirect to
`websecure` with public port `443`; TLS routes are pinned to `websecure`. This
keeps the internal ACME challenge router separate from backend routes. Public Kubernetes
Ingress resources will opt into TLS using the same resolver.
The router must not terminate TLS, use a KeenDNS HTTPS proxy, rewrite SNI, or
+4 -5
View File
@@ -41,10 +41,9 @@ version. Inspect the live `HelmChart/traefik` values before applying a chart
override; do not assume that a values schema from another K3s release is
compatible.
For each public Ingress, pin the TLS route to `websecure`. The separate
`http-redirect.yaml` resource attaches a `redirectScheme` middleware to
`web`-only routes. Keeping the HTTP redirect separate prevents the internal
ACME challenge router from being sent to a backend.
For each public Ingress, pin the TLS route to `websecure`. Ordinary HTTP
requests are redirected by the Traefik `web` entrypoint to the public HTTPS
port `443`; no Kubernetes HTTP catch-all route is used.
The resulting TLS Ingress shape is:
@@ -73,7 +72,7 @@ installed K3s `HelmChart/traefik` with:
- `web` exposed on TCP `80` for the HTTP redirect and ACME HTTP-01;
- `websecure` exposed on TCP `443` for TLS termination;
- a permanent HTTP-to-HTTPS `redirectScheme` middleware on web-only routes;
- a permanent HTTP-to-HTTPS entrypoint redirect with public port `443`;
- the `letsencrypt` ACME resolver using HTTP-01 through `web` (Traefik's
ACME challenge handling remains available on the `web` entrypoint);
- persistent `/data/acme.json` storage through a `1Gi` PVC.
@@ -1,63 +0,0 @@
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: http-to-https
namespace: hermes
spec:
redirectScheme:
scheme: https
permanent: true
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: http-redirect
namespace: hermes
labels:
app.kubernetes.io/name: http-redirect
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web
traefik.ingress.kubernetes.io/router.middlewares: hermes-http-to-https@kubernetescrd
spec:
ingressClassName: traefik
rules:
- host: hermes.rudolf.keenetic.link
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hermes
port:
name: dashboard
- host: brencher.rudolf.keenetic.link
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: brencher-swarm
port:
name: http
- host: immich.rudolf.keenetic.link
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: immich-swarm
port:
name: http
- host: gitea.rudolf.keenetic.link
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: gitea-swarm
port:
name: http
@@ -3,5 +3,4 @@ kind: Kustomization
resources:
- swarm-backends.yaml
- traefik-https-config.yaml
- http-redirect.yaml
- public-ingress.yaml
@@ -25,6 +25,10 @@ spec:
additionalArguments:
- "--entrypoints.web.address=:8000/tcp"
- "--entrypoints.websecure.address=:8443/tcp"
- "--entrypoints.web.http.redirections.entrypoint.to=websecure"
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
- "--entrypoints.web.http.redirections.entrypoint.port=443"
- "--entrypoints.web.http.redirections.entrypoint.permanent=true"
- "--certificatesresolvers.letsencrypt.acme.email=rudolfss13@gmail.com"
- "--certificatesresolvers.letsencrypt.acme.storage=/data/acme.json"
- "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"