From 84b596f7cadbd3cb89e4f4b5bb971f12518a00d8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Fri, 25 Sep 2026 13:59:30 +0200 Subject: [PATCH] fix(proxy): only emit Caddy log_append on caddy-docker-proxy 2.9+ Caddy 2.7.6, shipped in the caddy-docker-proxy 2.8 image, rejects the whole Caddyfile when it contains log_append. Add Server::caddySupportsLogAppend(), which reads the image from the applied proxy configuration. Traffic analytics labels now add log_append only when the server runs 2.9 or newer and has no pending proxy change. - Change the default Caddy proxy image from 2.8-alpine to 2.13-alpine - ProxyPortParser now validates Docker Compose port ranges and random host ports. It returns only fixed host ports for the availability check and has a clearer validation message - After mkdir, chown only root-owned files and remove other-user access from the top directory only. Files owned by container users and the modes of mounted files no longer change - Add tests for log_append support and the new parser/sudo behaviour - Note in the lessons file that tests must flush the Server identity map between dataset cases --- .ai/lessons.md | 1 + app/Models/Server.php | 24 ++++++ app/Services/ProxyPortParser.php | 66 +++++++++++----- bootstrap/helpers/docker.php | 11 ++- bootstrap/helpers/proxy.php | 2 +- bootstrap/helpers/sudo.php | 14 +++- tests/Feature/Api/ServerProxyApiTest.php | 2 +- .../CaddyLogAppendSupportTest.php | 78 +++++++++++++++++++ .../TrafficAnalytics/CaddyProxyVolumeTest.php | 12 +++ .../CaddyTrafficLabelsTest.php | 10 ++- tests/Unit/ParseCommandsByLineForSudoTest.php | 46 ++++++++++- tests/Unit/ProxyPortValidationTest.php | 12 +++ 12 files changed, 248 insertions(+), 30 deletions(-) create mode 100644 tests/Feature/TrafficAnalytics/CaddyLogAppendSupportTest.php diff --git a/.ai/lessons.md b/.ai/lessons.md index b27b690bd8..e596a86c16 100644 --- a/.ai/lessons.md +++ b/.ai/lessons.md @@ -62,6 +62,7 @@ ## Test the real runtime image - Deployment shell commands run in the Alpine/BusyBox helper image and pass through the non-root sudo parser. Verify new flags and shell syntax in that image and with `parseCommandsByLineForSudo()`; faked command output hides both failures. - Put multi-step remote shell logic in one `sh -c '