feat: render proxy routes under openresty and add per-backend tests

Bumps the openresty sidecar to 0.12.0, which introduces the openresty.route.<n>.* label family for path-based routing. The openresty-vhosts plugin now emits route labels for non-web containers targeted by a proxy:route:set, mirroring the traefik and caddy patterns. Adds integration tests for every rendering backend (proxy-route-{nginx,traefik,caddy,openresty}.bats covering basic routing, --strip-prefix, and removal) plus per-ingress-class scheduler-k3s tests (proxy-route-k3s-{nginx,traefik}.bats covering the same three cases against a real cluster). The nginx file additionally asserts the rendered nginx config carries the WebSocket upgrade headers in each route's location block.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-11-04 14:56:38 -05:00
1 parent a4d40becd8
commit 4a550fe4b9
11 files changed
+644 -20

No files matched your search

@@ -12,11 +12,26 @@ trigger-openresty-vhosts-docker-args-process-deploy() {
local include_dir output value DATA
local STDIN=$(cat)
if [[ "$PROC_TYPE" != "web" ]]; then
if [[ "$(plugn trigger proxy-type "$APP")" != "openresty" ]] && [[ "$(plugn trigger proxy-type "$APP")" != "nginx" ]]; then
return
fi
if [[ "$(plugn trigger proxy-type "$APP")" != "openresty" ]] && [[ "$(plugn trigger proxy-type "$APP")" != "nginx" ]]; then
if [[ "$PROC_TYPE" != "web" ]]; then
# Non-web processes are only labeled when at least one path-based route
# targets the process. Otherwise openresty should ignore the container.
local route_proc
local has_route=false
while IFS='|' read -r route_proc _ _ _; do
if [[ "$route_proc" == "$PROC_TYPE" ]]; then
has_route=true
break
fi
done < <(plugn trigger proxy-routes-list "$APP")
if [[ "$has_route" != "true" ]]; then
echo -n "$STDIN"
return
fi
fn-openresty-route-labels "$APP" "$PROC_TYPE" "$STDIN"
return
fi
@@ -11,6 +11,35 @@ fn-get-pagesize() {
"$PLUGIN_CORE_AVAILABLE_PATH/nginx-vhosts/pagesize"
}
fn-openresty-route-labels() {
declare desc="emits per-route openresty labels for a non-web container"
declare APP="$1" PROC_TYPE="$2" STDIN="$3"
local output route_proc route_port route_path route_strip route_index=0
output=""
while IFS='|' read -r route_proc route_port route_path route_strip; do
[[ -z "$route_proc" ]] && continue
[[ "$route_proc" != "$PROC_TYPE" ]] && continue
output="$output --label 'openresty.route.${route_index}.path-prefix=${route_path}'"
output="$output --label 'openresty.route.${route_index}.port=${route_port}'"
if [[ "$route_strip" == "1" ]]; then
output="$output --label 'openresty.route.${route_index}.strip-prefix=true'"
fi
route_index=$((route_index + 1))
done < <(plugn trigger proxy-routes-list "$APP")
local proxy_labels_file_path=$(fn-proxy-get-labels-file-path "openresty" "$APP")
if [[ -f "$proxy_labels_file_path" ]]; then
while read -r line; do
[[ -z "$line" ]] && continue
output="$output --label '$line'"
done <"$proxy_labels_file_path"
fi
echo -n "$STDIN $output"
}
fn-openresty-access-log-format() {
declare desc="get the raw per-app access log format"
declare APP="$1"
+1 -1
View File
@@ -105,7 +105,7 @@ func CommandRouteClear(appName string) error {
// labels are baked in at create-time).
func warnIfRebuildRequired(appName string) {
switch getComputedProxyType(appName) {
case "traefik", "caddy":
case "traefik", "caddy", "openresty":
common.LogWarn(fmt.Sprintf(
"Routes are applied via container labels under the %s proxy backend; run `dokku ps:rebuild %s` to recreate containers and pick up the change",
getComputedProxyType(appName), appName,