Files
dokku/plugins/haproxy-vhosts/internal-functions
T
Joao Gilberto Magalhaes 4887cf458e fix: haproxy letsencrypt integration and upgrade EasyHAProxy to 6.5.1
The letsencrypt integration set EASYHAPROXY_LETSENCRYPT_EMAIL (with a stray
quote) and a letsencrypt label, which EasyHAProxy has not read since before
4.6.0. With an email set, http redirected to https and nothing answered on 443.

- Pass EASYHAPROXY_CERTBOT_EMAIL and EASYHAPROXY_CERTBOT_SERVER.
- Label the app with certbot=true on its http definition: EasyHAProxy requests
  the certificate and serves https itself, so the separate 443 definition goes.
  https labels are only added when a letsencrypt email is set, as documented.
- Keep the certificates in /var/lib/dokku/data/haproxy.
- Turn the stats page off with HAPROXY_STATS_ENABLE=false.
- Upgrade EasyHAProxy from 6.1.1 to 6.5.1.
2026-10-23 09:29:01 -04:00

107 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/env bash
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
fn-haproxy-logs() {
declare desc="shows the logs for the haproxy container"
declare TAIL="$1" NUM="$2"
local dokku_logs_args=("--tail" "$NUM")
if [[ "$TAIL" == "true" ]]; then
dokku_logs_args+=("--follow")
fi
"$DOCKER_BIN" logs haproxy-haproxy-1 "${dokku_logs_args[@]}"
}
fn-haproxy-logs-usage() {
declare desc="logs specific usage"
echo "Usage: dokku haproxy:logs"
echo " display recent haproxy log output"
echo ""
echo " -n, --num NUM # the number of lines to display"
echo " -t, --tail # continually stream logs"
}
fn-haproxy-template-compose-file() {
declare desc="templates out the compose file"
declare OUTPUT_PATH="$1"
local COMPOSE_TEMPLATE="$PLUGIN_AVAILABLE_PATH/haproxy-vhosts/templates/compose.yml.sigil"
CUSTOM_COMPOSE_TEMPLATE="$(plugn trigger haproxy-template-source "$APP")"
if [[ -n "$CUSTOM_COMPOSE_TEMPLATE" ]]; then
COMPOSE_TEMPLATE="$CUSTOM_COMPOSE_TEMPLATE"
fi
local SIGIL_PARAMS=(HAPROXY_IMAGE="$(fn-haproxy-computed-image)"
HAPROXY_LOG_LEVEL="$(fn-haproxy-computed-log-level)"
HAPROXY_LETSENCRYPT_EMAIL="$(fn-haproxy-computed-letsencrypt-email)"
HAPROXY_LETSENCRYPT_SERVER="$(fn-haproxy-computed-letsencrypt-server)"
HAPROXY_REFRESH_CONF="$(fn-haproxy-computed-refresh-conf)"
HAPROXY_DATA_DIR="${DOKKU_LIB_ROOT}/data/haproxy")
sigil -f "$COMPOSE_TEMPLATE" "${SIGIL_PARAMS[@]}" | cat -s >"$OUTPUT_PATH"
}
fn-haproxy-global-image() {
fn-plugin-property-get-default "haproxy" "--global" "image" ""
}
fn-haproxy-computed-image() {
local value
value="$(fn-haproxy-global-image)"
if [[ -z "$value" ]]; then
value="$(grep "FROM" "$PLUGIN_AVAILABLE_PATH/haproxy-vhosts/Dockerfile" | awk '{print $2}')"
fi
echo "$value"
}
fn-haproxy-global-log-level() {
fn-plugin-property-get-default "haproxy" "--global" "log-level" ""
}
fn-haproxy-computed-log-level() {
local value
value="$(fn-haproxy-global-log-level)"
if [[ -z "$value" ]]; then
value="ERROR"
fi
echo "${value^^}"
}
fn-haproxy-global-letsencrypt-email() {
fn-plugin-property-get-default "haproxy" "--global" "letsencrypt-email" ""
}
fn-haproxy-computed-letsencrypt-email() {
fn-haproxy-global-letsencrypt-email
}
fn-haproxy-global-letsencrypt-server() {
fn-plugin-property-get-default "haproxy" "--global" "letsencrypt-server" ""
}
fn-haproxy-computed-letsencrypt-server() {
local value
value="$(fn-haproxy-global-letsencrypt-server)"
if [[ -z "$value" ]]; then
value="https://acme-v02.api.letsencrypt.org/directory"
fi
echo "$value"
}
fn-haproxy-global-refresh-conf() {
fn-plugin-property-get-default "haproxy" "--global" "refresh-conf" ""
}
fn-haproxy-computed-refresh-conf() {
local value
value="$(fn-haproxy-global-refresh-conf)"
if [[ -z "$value" ]]; then
value="10"
fi
echo "$value"
}