fix(ingress): isolate HTTP redirect from ACME
This commit is contained in:
@@ -32,10 +32,10 @@ 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 requests on `web` are permanently redirected to
|
||||
`websecure`; Traefik's internal ACME challenge handling remains available for
|
||||
HTTP-01 validation. Public Kubernetes Ingress resources will opt into TLS using
|
||||
the same resolver.
|
||||
(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
|
||||
Ingress resources will opt into TLS using the same resolver.
|
||||
|
||||
The router must not terminate TLS, use a KeenDNS HTTPS proxy, rewrite SNI, or
|
||||
replace the HTTP `Host` header on the forwarded path.
|
||||
|
||||
@@ -5,6 +5,7 @@ metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: hermes
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
||||
traefik.ingress.kubernetes.io/router.tls: "true"
|
||||
traefik.ingress.kubernetes.io/router.tls.certresolver: letsencrypt
|
||||
spec:
|
||||
|
||||
@@ -41,12 +41,17 @@ 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, enable TLS with the same resolver. The resulting
|
||||
Ingress shape is:
|
||||
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.
|
||||
|
||||
The resulting TLS Ingress shape is:
|
||||
|
||||
```yaml
|
||||
metadata:
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
||||
traefik.ingress.kubernetes.io/router.tls: "true"
|
||||
traefik.ingress.kubernetes.io/router.tls.certresolver: letsencrypt
|
||||
spec:
|
||||
@@ -66,9 +71,9 @@ private key, an API token, or an unencrypted Kubernetes Secret.
|
||||
The repository configuration is in `traefik-https-config.yaml`. It extends the
|
||||
installed K3s `HelmChart/traefik` with:
|
||||
|
||||
- `web` exposed on TCP `80`;
|
||||
- `websecure` exposed on TCP `443`;
|
||||
- permanent HTTP-to-HTTPS redirection from `web` to `websecure`;
|
||||
- `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;
|
||||
- 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.
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
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,4 +3,5 @@ kind: Kustomization
|
||||
resources:
|
||||
- swarm-backends.yaml
|
||||
- traefik-https-config.yaml
|
||||
- http-redirect.yaml
|
||||
- public-ingress.yaml
|
||||
|
||||
@@ -6,6 +6,7 @@ metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: public-ingress
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.entrypoints: websecure
|
||||
traefik.ingress.kubernetes.io/router.tls: "true"
|
||||
traefik.ingress.kubernetes.io/router.tls.certresolver: letsencrypt
|
||||
spec:
|
||||
|
||||
@@ -25,9 +25,6 @@ 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.permanent=true"
|
||||
- "--certificatesresolvers.letsencrypt.acme.email=rudolfss13@gmail.com"
|
||||
- "--certificatesresolvers.letsencrypt.acme.storage=/data/acme.json"
|
||||
- "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
|
||||
|
||||
Reference in New Issue
Block a user