feat: route paths to non-web processes via proxy:route

Adds proxy:route:set/remove/clear/report so users can declare path-prefix routes to non-web Procfile processes without hand-writing nginx.conf.sigil. Routes are stored on the proxy plugin as a PropertyMap of path to process:port:strip, with set semantics so each invocation produces a fully-determined state and re-application is idempotent. A proxy-supports-routes capability trigger gates the command per backend - nginx-vhosts, traefik-vhosts, caddy-vhosts, and scheduler-k3s render routes today; openresty-vhosts and haproxy-vhosts refuse until their sidecar images learn a path-prefix vocabulary (tracked in dokku/openresty-docker-proxy#137 and the haproxy sidecar). Closes #8725.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-11-04 14:56:38 -05:00
1 parent 2cd558e102
commit ffd5248cc3
29 files changed
+1539 -7

No files matched your search

@@ -38,6 +38,28 @@ spec:
- {{ $entryPoint }}
routes:
{{- range $ddx, $domain := $config.web.domains }}
{{- range $rdx, $route := $.Values.global.network.routes }}
- kind: Rule
match: Host(`{{ $domain.name }}`) && PathPrefix(`{{ $route.path }}`)
priority: {{ len $route.path }}
middlewares:
- name: {{ $.Values.global.app_name}}-{{ $processName }}-compression
namespace: {{ $.Values.global.namespace }}
{{- if and (eq $entryPoint "web") $config.web.tls.enabled }}
- name: {{ $.Values.global.app_name}}-{{ $processName }}-redirect-to-https
namespace: {{ $.Values.global.namespace }}
{{- end }}
{{- if $route.strip_prefix }}
- name: {{ $.Values.global.app_name }}-{{ $route.process }}-{{ $route.slug }}-strip
namespace: {{ $.Values.global.namespace }}
{{- end }}
services:
- name: {{ $.Values.global.app_name }}-{{ $route.process }}
namespace: {{ $.Values.global.namespace }}
passHostHeader: true
port: {{ $route.port }}
scheme: http
{{- end }}
- kind: Rule
match: {{ include "traefik.host.match" $domain.name }}
{{- if hasPrefix "*." $domain.name }}
@@ -65,6 +65,76 @@ spec:
{{- end }}
path: /
{{- end }}
{{- range $rdx, $route := $.Values.global.network.routes }}
{{- if not $route.strip_prefix }}
- backend:
service:
name: {{ $.Values.global.app_name }}-{{ $route.process }}
port:
number: {{ $route.port }}
pathType: Prefix
path: {{ $route.path }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- /* Strip-prefix routes need their own Ingress objects because the
rewrite-target annotation is Ingress-level. */}}
{{- range $processName, $config := .Values.processes }}
{{- if not (hasKey $config "web") }}
{{- continue }}
{{- end }}
{{- if and $config.web.domains (eq $.Values.global.network.ingress_class "nginx") }}
{{- range $pdx, $domain := $config.web.domains }}
{{- range $rdx, $route := $.Values.global.network.routes }}
{{- if $route.strip_prefix }}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
dokku.com/managed: "true"
dokku.com/ingress-method: "routes"
nginx.ingress.kubernetes.io/rewrite-target: /$2
{{- if $config.web.tls.enabled }}
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
{{- end }}
{{ include "print.annotations" (dict "config" $.Values.global "key" "ingress") | indent 4 }}
{{ include "print.annotations" (dict "config" $config "key" "ingress") | indent 4 }}
labels:
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $route.process }}
app.kubernetes.io/name: {{ $route.process }}
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
{{ include "print.labels" (dict "config" $.Values.global "key" "ingress") | indent 4 }}
{{ include "print.labels" (dict "config" $config "key" "ingress") | indent 4 }}
name: {{ $.Values.global.app_name }}-{{ $route.process }}-{{ $route.slug }}-strip-{{ $domain.slug }}
namespace: {{ $.Values.global.namespace }}
spec:
ingressClassName: nginx
{{- if $config.web.tls.enabled }}
tls:
- hosts:
- {{ $domain.name | quote }}
{{- if $config.web.tls.use_imported_cert }}
secretName: tls-{{ $.Values.global.app_name }}
{{- else }}
secretName: tls-{{ $.Values.global.app_name }}-{{ $processName }}
{{- end }}
{{- end }}
rules:
- host: {{ $domain.name | quote }}
http:
paths:
- backend:
service:
name: {{ $.Values.global.app_name }}-{{ $route.process }}
port:
number: {{ $route.port }}
pathType: ImplementationSpecific
path: {{ $route.path }}(/|$)(.*)
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,35 @@
{{- /* Emit a StripPrefix Middleware CRD per route that uses --strip-prefix
when the ingress class is traefik. Referenced from the IngressRoute
Rule rendered in ingress-route.yaml. */}}
{{- range $processName, $config := .Values.processes }}
{{- if not (hasKey $config "web") }}
{{- continue }}
{{- end }}
{{- if and $config.web.domains (eq $.Values.global.network.ingress_class "traefik") }}
{{- range $rdx, $route := $.Values.global.network.routes }}
{{- if $route.strip_prefix }}
---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
annotations:
dokku.com/managed: "true"
{{ include "print.annotations" (dict "config" $.Values.global "key" "traefik_middleware") | indent 4 }}
{{ include "print.annotations" (dict "config" $config "key" "traefik_middleware") | indent 4 }}
labels:
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $route.process }}-{{ $route.slug }}-strip
app.kubernetes.io/name: {{ $route.process }}
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
{{ include "print.labels" (dict "config" $.Values.global "key" "traefik_middleware") | indent 4 }}
{{ include "print.labels" (dict "config" $config "key" "traefik_middleware") | indent 4 }}
name: {{ $.Values.global.app_name }}-{{ $route.process }}-{{ $route.slug }}-strip
namespace: {{ $.Values.global.namespace }}
spec:
stripPrefix:
prefixes:
- {{ $route.path }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}