|
| 1 | +# Wildcard TLS for the NTunl host (direct-to-IP, no Cloudflare proxy) |
| 2 | + |
| 3 | +When you route `*.<domain>` straight at the k3s ingress IP with a **DNS-only** |
| 4 | +wildcard A record (instead of through a Cloudflare proxied tunnel), Cloudflare's |
| 5 | +edge certificate no longer applies — you must terminate TLS yourself. These |
| 6 | +manifests issue a Let's Encrypt **wildcard** cert via cert-manager + Cloudflare |
| 7 | +DNS-01 and hand it to the Ingress. |
| 8 | + |
| 9 | +These are intentionally **not** part of the top-level `kustomization.yaml`: they |
| 10 | +depend on cert-manager's CRDs, which must be installed first. |
| 11 | + |
| 12 | +## Steps |
| 13 | + |
| 14 | +1. **Install cert-manager** (one-time, cluster-wide): |
| 15 | + ```bash |
| 16 | + kubectl apply -f https://github.com/cert-manager/cert-manager/releases/latest/download/cert-manager.yaml |
| 17 | + ``` |
| 18 | + |
| 19 | +2. **DNS** — point a wildcard at your ingress IP, **DNS-only / grey cloud** |
| 20 | + (proxied wildcards are Enterprise-only and won't work here): |
| 21 | + ``` |
| 22 | + *.example.com A <traefik external IP> |
| 23 | + ``` |
| 24 | + Find the IP: `kubectl -n kube-system get svc traefik -o wide`. |
| 25 | + |
| 26 | +3. **Cloudflare API token** — create one (Zone:DNS:Edit + Zone:Zone:Read on your |
| 27 | + zone), put it in `cloudflare-api-token-secret.yaml`, and apply it into the |
| 28 | + `cert-manager` namespace. |
| 29 | + |
| 30 | +4. **Edit the domain/email** in `clusterissuer.yaml` and `certificate.yaml` |
| 31 | + (replace `example.com` and the email). Tip: use the Let's Encrypt **staging** |
| 32 | + server first to avoid rate limits, then switch to prod. |
| 33 | + |
| 34 | +5. **Apply**: |
| 35 | + ```bash |
| 36 | + kubectl apply -f deploy/k3s/cert-manager/cloudflare-api-token-secret.yaml |
| 37 | + kubectl apply -f deploy/k3s/cert-manager/clusterissuer.yaml |
| 38 | + kubectl apply -f deploy/k3s/cert-manager/certificate.yaml |
| 39 | + ``` |
| 40 | + |
| 41 | +6. **Verify** the cert was issued into the `ntunl-wildcard-tls` secret that the |
| 42 | + Ingress references: |
| 43 | + ```bash |
| 44 | + kubectl -n ntunl get certificate ntunl-wildcard |
| 45 | + kubectl -n ntunl describe certificate ntunl-wildcard # watch for "Issued" |
| 46 | + ``` |
| 47 | + |
| 48 | +The Ingress (`../ingress.yaml`) already references `secretName: ntunl-wildcard-tls`, |
| 49 | +so once the cert is `Ready`, `https://<sub>.example.com` and `wss://tunnel...` |
| 50 | +serve a valid certificate. |
| 51 | + |
| 52 | +## Client config for this path |
| 53 | + |
| 54 | +Because TLS is now terminated at Traefik on 443: |
| 55 | + |
| 56 | +```jsonc |
| 57 | +{ |
| 58 | + "sslEnabled": true, |
| 59 | + "allowInvalidCertificates": false, // real Let's Encrypt cert |
| 60 | + "ntunlAddress": "tunnel.example.com:443" |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +## Trade-off vs. Cloudflare Tunnel |
| 65 | + |
| 66 | +Direct-to-IP exposes your node's public IP and you manage TLS yourself, but it's |
| 67 | +the only way to get wildcard/dynamic subdomains without a Cloudflare Enterprise |
| 68 | +plan. The portal and tunnel-handshake hostnames could still go through a |
| 69 | +Cloudflare proxied tunnel if you prefer to hide those two — but the wildcard |
| 70 | +proxy must be direct. |
0 commit comments