Files
dokku/plugins/nginx-vhosts/pre-enable-vhost
T
Jose Diaz-Gonzalez af6267f3b5 fix: restore default domains and reset proxy ports on vhost enable
Re-enabling vhost (via `proxy:enable`, `domains:enable`, or `domains:add` with no global VHOST) was leaving the app pinned to the random high port and the empty VHOST file from the previous disabled state, so the new catch-all vhost intercepted requests for the app's domain. The `domains-enable` trigger now restores default vhosts via `domains_enable`, and `pre-enable-vhost` clears any stored proxy ports so they can be recomputed to 80/443. Also fixes the netrc lookup in the `git:auth` test to read dokku's netrc file directly.
2026-04-27 14:43:20 -04:00

38 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
trigger-nginx-vhosts-pre-enable-vhost() {
declare desc="unset port prior to vhosts being enabled"
declare trigger="pre-enable-vhost"
declare APP="$1"
if [[ "$(plugn trigger proxy-type "$APP")" != "nginx" ]]; then
return
fi
# clear stored proxy ports so they can be recomputed for the enabled state
local PROXY_PORT=$(plugn trigger ports-get-property "$APP" "proxy-port")
local PROXY_SSL_PORT=$(plugn trigger ports-get-property "$APP" "proxy-ssl-port")
if [[ -n "$PROXY_PORT" ]]; then
fn-plugin-property-delete "proxy" "$APP" "proxy-port"
fi
if [[ -n "$PROXY_SSL_PORT" ]]; then
fn-plugin-property-delete "proxy" "$APP" "proxy-ssl-port"
fi
# clear ports if there is a mapping starting with http:80 or https:443
local PORT_MAPS=$(plugn trigger ports-get "$APP")
for PORT_MAP in $PORT_MAPS; do
if [[ "$PORT_MAP" == "http:80:"* ]] || [[ "$PORT_MAP" == "https:443:"* ]]; then
plugn trigger ports-clear "$APP"
break
fi
done
}
trigger-nginx-vhosts-pre-enable-vhost "$@"