From 0031108160ad440d6d2f172dba07c04e6f5af4a8 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 18 Jan 2023 13:01:45 +0100 Subject: [PATCH] icingacli setup config webserver apache: add trailing / to Alias dir if the Alias URI (e.g. /) has a trailing /. Otherwise Apache says 403. --- modules/setup/library/Setup/Webserver.php | 2 ++ modules/setup/library/Setup/Webserver/Apache.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/setup/library/Setup/Webserver.php b/modules/setup/library/Setup/Webserver.php index 145a3c9a1..2251ba3d9 100644 --- a/modules/setup/library/Setup/Webserver.php +++ b/modules/setup/library/Setup/Webserver.php @@ -76,12 +76,14 @@ abstract class Webserver $searchTokens = array( '{urlPath}', '{documentRoot}', + '{aliasDocumentRoot}', '{configDir}', '{fpmUri}' ); $replaceTokens = array( $this->getUrlPath(), $this->getDocumentRoot(), + preg_match('~/$~', $this->getUrlPath()) ? $this->getDocumentRoot() . '/' : $this->getDocumentRoot(), $this->getConfigDir(), $this->getFpmUri() ); diff --git a/modules/setup/library/Setup/Webserver/Apache.php b/modules/setup/library/Setup/Webserver/Apache.php index 57c8513a6..fdb367f8f 100644 --- a/modules/setup/library/Setup/Webserver/Apache.php +++ b/modules/setup/library/Setup/Webserver/Apache.php @@ -16,7 +16,7 @@ class Apache extends Webserver { if (! $this->enableFpm) { return <<<'EOD' -Alias {urlPath} "{documentRoot}" +Alias {urlPath} "{aliasDocumentRoot}" # Remove comments if you want to use PHP FPM and your Apache version is older than 2.4 # @@ -79,7 +79,7 @@ Alias {urlPath} "{documentRoot}" EOD; } else { return <<<'EOD' -Alias {urlPath} "{documentRoot}" +Alias {urlPath} "{aliasDocumentRoot}" # Forward PHP requests to FPM