diff --git a/templates/public-ingress.yaml b/templates/public-ingress.yaml new file mode 100644 index 0000000..41c6dea --- /dev/null +++ b/templates/public-ingress.yaml @@ -0,0 +1,87 @@ +{{- /* +Optional public ingress per app (apps..publicIngress.host). Unlike the regular +ingress it has NO LAN whitelist; protection instead: + - GeoIP: ingress-nginx answers the host only for clients from DE (map $geo_restricted_host + in the ingress-nginx values in apps-in-apps - the host has to be listed there too!) + - rate limits per client IP, and a much stricter one for the login endpoints +The DNS record must point at the public IP (DNS-only, NOT proxied through Cloudflare: +video over Cloudflare's free CDN violates their terms). +*/ -}} +{{- $root := . }} +{{- range $name, $app := .Values.apps }} +{{- if and $app.enabled $app.publicIngress }} +{{- $host := required (printf "apps.%s.publicIngress.host is required" $name) $app.publicIngress.host }} +{{- $common := dict "nginx.ingress.kubernetes.io/proxy-body-size" "100m" }} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $name }}-public + namespace: {{ $root.Values.namespace }} + labels: + app.kubernetes.io/name: {{ $name }} + {{- include "media.labels" $root | nindent 4 }} + annotations: + # Only this ingress requests the certificate; -public-login reuses the secret. + cert-manager.io/cluster-issuer: {{ $root.Values.ingress.clusterIssuer }} + {{- toYaml $common | nindent 4 }} + nginx.ingress.kubernetes.io/limit-rps: {{ $app.publicIngress.limitRps | default "30" | quote }} + nginx.ingress.kubernetes.io/limit-burst-multiplier: "5" + nginx.ingress.kubernetes.io/limit-connections: {{ $app.publicIngress.limitConnections | default "30" | quote }} + {{- with $app.ingressAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + ingressClassName: {{ $root.Values.ingress.className }} + tls: + - hosts: + - {{ $host }} + secretName: {{ $name }}-public-tls + rules: + - host: {{ $host }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ $name }} + port: + name: http +{{- with $app.publicIngress.loginPaths }} +--- +# Same host, login/password-reset endpoints only: at most 10 attempts per minute per IP. +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $name }}-public-login + namespace: {{ $root.Values.namespace }} + labels: + app.kubernetes.io/name: {{ $name }} + {{- include "media.labels" $root | nindent 4 }} + annotations: + {{- toYaml $common | nindent 4 }} + nginx.ingress.kubernetes.io/limit-rpm: "10" + nginx.ingress.kubernetes.io/limit-burst-multiplier: "1" +spec: + ingressClassName: {{ $root.Values.ingress.className }} + tls: + - hosts: + - {{ $host }} + secretName: {{ $name }}-public-tls + rules: + - host: {{ $host }} + http: + paths: + {{- range . }} + - path: {{ . }} + pathType: Prefix + backend: + service: + name: {{ $name }} + port: + name: http + {{- end }} +{{- end }} +{{- end }} +{{- end }} diff --git a/values.yaml b/values.yaml index a40dcb3..b200113 100644 --- a/values.yaml +++ b/values.yaml @@ -73,6 +73,16 @@ apps: # Intel QuickSync (UHD 630): requests gpu.intel.com/i915 from the Intel GPU device # plugin (apps-in-apps: intel-gpu-plugin), which injects /dev/dri. Not privileged. gpu: true + # Remote access without VPN (templates/public-ingress.yaml): DE-only via GeoIP in + # ingress-nginx, rate limited. jellyfin.smokyzone.de stays LAN/Tailscale-only. + publicIngress: + host: tv.smokyzone.de + # Jellyfin's routing is case-insensitive, nginx paths are not -> both spellings. + loginPaths: + - /Users/AuthenticateByName + - /users/authenticatebyname + - /Users/ForgotPassword + - /users/forgotpassword ingressAnnotations: nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"