From 85d07283222934682bf5c988754f954798e1c870 Mon Sep 17 00:00:00 2001 From: konstchri <79702630+konstchri@users.noreply.github.com> Date: Tue, 12 Nov 2024 16:21:45 +0200 Subject: [PATCH 1/2] [Fix]: Caddy docker labels do not honor "strip prefix" option --- bootstrap/helpers/docker.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 40eacf5c8..98039ba4b 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -283,6 +283,10 @@ function fqdnLabelsForCaddy(string $network, string $uuid, Collection $domains, $host_without_www = str($host)->replace('www.', ''); $schema = $url->getScheme(); $port = $url->getPort(); + $handle = "handle_path" + if ( ! $is_stripprefix_enabled){ + $handle = "handle" + } if (is_null($port) && ! is_null($onlyPort)) { $port = $onlyPort; } @@ -293,12 +297,13 @@ function fqdnLabelsForCaddy(string $network, string $uuid, Collection $domains, $labels->push("caddy_{$loop}.header=-Server"); $labels->push("caddy_{$loop}.try_files={path} /index.html /index.php"); + if ($port) { - $labels->push("caddy_{$loop}.handle_path.{$loop}_reverse_proxy={{upstreams $port}}"); + $labels->push("caddy_{$loop}.{$handle}.{$loop}_reverse_proxy={{upstreams $port}}"); } else { - $labels->push("caddy_{$loop}.handle_path.{$loop}_reverse_proxy={{upstreams}}"); + $labels->push("caddy_{$loop}.{$handle}.{$loop}_reverse_proxy={{upstreams}}"); } - $labels->push("caddy_{$loop}.handle_path={$path}*"); + $labels->push("caddy_{$loop}.{$handle}={$path}*"); if ($is_gzip_enabled) { $labels->push("caddy_{$loop}.encode=zstd gzip"); } From 1a27196e1abc53957ba2a2cf1048fc5bf34a7f9e Mon Sep 17 00:00:00 2001 From: Konstantinos Christoforou Date: Tue, 12 Nov 2024 19:22:07 +0200 Subject: [PATCH 2/2] fix typo --- bootstrap/helpers/docker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 98039ba4b..ca933e6ae 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -283,9 +283,9 @@ function fqdnLabelsForCaddy(string $network, string $uuid, Collection $domains, $host_without_www = str($host)->replace('www.', ''); $schema = $url->getScheme(); $port = $url->getPort(); - $handle = "handle_path" + $handle = "handle_path"; if ( ! $is_stripprefix_enabled){ - $handle = "handle" + $handle = "handle"; } if (is_null($port) && ! is_null($onlyPort)) { $port = $onlyPort;