From 828e0e8face4f56e9a38f8708d8b8cec0b9fe577 Mon Sep 17 00:00:00 2001 From: Coffee2CodeNL Date: Sun, 7 Apr 2024 14:24:06 +0200 Subject: [PATCH] custom HTTP and HTTPS entry points The code changes add the capability to configure custom HTTP and HTTPS entry points for the Traefik virtual hosts plugin. New settings have been added to the list of valid and global keys. Also, function definitions for retrieving default HTTP and HTTPS entry points were included in the internal functions file. Furthermore, the 'docker-args-process-deploy' script now considers the new entry points while processing deployment arguments. Also fixed a typo in set, line 13: "dashboard"-enabled -> "dashboard-enabled" --- plugins/traefik-vhosts/docker-args-process-deploy | 6 +++--- plugins/traefik-vhosts/internal-functions | 8 ++++++++ plugins/traefik-vhosts/subcommands/set | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/traefik-vhosts/docker-args-process-deploy b/plugins/traefik-vhosts/docker-args-process-deploy index 6cb1c8da4..22a3b358d 100755 --- a/plugins/traefik-vhosts/docker-args-process-deploy +++ b/plugins/traefik-vhosts/docker-args-process-deploy @@ -7,7 +7,7 @@ set -eo pipefail trigger-traefik-vhosts-docker-args-process-deploy() { declare desc="nginx-vhosts core-post-deploy plugin trigger" declare trigger="docker-args-process-deploy" - declare APP="$1" IMAGE_SOURCE_TYPE="$2" IMAGE_TAG="$3" PROC_TYPE="$4" CONTAINER_INDEX="$5" + declare APP="$1" IMAGE_SOURCE_TYPE="$2" IMAGE_TAG="$3" PROC_TYPE="$4" CONTAINER_INDEX="$5" HTTP_ENTRY_POINT="$6" HTTPS_ENTRY_POINT="$7" local app_domains is_app_listening letsencrypt_email output proxy_container_port proxy_host_port port_map proxy_scheme proxy_schemes traefik_domains local proxy_container_http_port proxy_container_http_port_candidate proxy_host_http_port_candidate local proxy_container_https_port proxy_container_https_port_candidate proxy_host_https_port_candidate @@ -96,7 +96,7 @@ trigger-traefik-vhosts-docker-args-process-deploy() { fi output="$output --label traefik.http.services.$APP-$PROC_TYPE-http.loadbalancer.server.port=$proxy_container_http_port" - output="$output --label traefik.http.routers.$APP-$PROC_TYPE-http.entrypoints=http" + output="$output --label traefik.http.routers.$APP-$PROC_TYPE-http.entrypoints=$(fn-traefik-http-entry-point)" output="$output --label traefik.http.routers.$APP-$PROC_TYPE-http.service=$APP-$PROC_TYPE-http" if [[ -n "$traefik_domains" ]]; then output="$output --label \"traefik.http.routers.$APP-$PROC_TYPE-http.rule=Host(\\\`$traefik_domains\\\`)\"" @@ -111,7 +111,7 @@ trigger-traefik-vhosts-docker-args-process-deploy() { fi output="$output --label traefik.http.services.$APP-$PROC_TYPE-https.loadbalancer.server.port=$proxy_container_https_port" - output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.entrypoints=https" + output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.entrypoints=$(fn-traefik-https-entry-point)" output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.service=$APP-$PROC_TYPE-https" output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.tls.certresolver=leresolver" if [[ -n "$traefik_domains" ]]; then diff --git a/plugins/traefik-vhosts/internal-functions b/plugins/traefik-vhosts/internal-functions index ce981215d..e36e5338b 100755 --- a/plugins/traefik-vhosts/internal-functions +++ b/plugins/traefik-vhosts/internal-functions @@ -92,3 +92,11 @@ fn-traefik-log-level() { log_level="$(fn-plugin-property-get-default "traefik" "--global" "log-level" "ERROR")" echo "${log_level^^}" } + +fn-traefik-http-entry-point() { + fn-plugin-property-get-default "traefik" "--global" "http-entry-point" "http" +} + +fn-traefik-https-entry-point() { + fn-plugin-property-get-default "traefik" "--global" "https-entry-point" "https" +} diff --git a/plugins/traefik-vhosts/subcommands/set b/plugins/traefik-vhosts/subcommands/set index c9a10476b..867386618 100755 --- a/plugins/traefik-vhosts/subcommands/set +++ b/plugins/traefik-vhosts/subcommands/set @@ -9,8 +9,8 @@ cmd-traefik-set() { declare cmd="traefik:set" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" KEY="$2" VALUE="$3" - local VALID_KEYS=("api-enabled" "api-vhost" "dashboard-enabled" "basic-auth-username" "basic-auth-password" "image" "letsencrypt-email" "letsencrypt-server" "log-level") - local GLOBAL_KEYS=("api-enabled" "api-vhost" "dashboard"-enabled "basic-auth-username" "basic-auth-password" "image" "letsencrypt-email" "letsencrypt-server" "log-level") + local VALID_KEYS=("api-enabled" "api-vhost" "dashboard-enabled" "basic-auth-username" "basic-auth-password" "image" "letsencrypt-email" "letsencrypt-server" "log-level" "http-entry-point" "https-entry-point") + local GLOBAL_KEYS=("api-enabled" "api-vhost" "dashboard-enabled" "basic-auth-username" "basic-auth-password" "image" "letsencrypt-email" "letsencrypt-server" "log-level" "http-entry-point" "https-entry-point") [[ -z "$KEY" ]] && dokku_log_fail "No key specified"