From 5a329cdd48bd1d1d57119b12dbafe16244ac3d13 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 3 Aug 2026 18:43:02 +0000 Subject: [PATCH] traccar: resolve Caddy local/remote mode like configure_caddy_for_service does MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The caddy_net wiring for the new db/traccar containers was gated only on whether ~/docker/caddy exists locally, so it didn't account for a site where Caddy runs on a different box (CADDY_MODE=remote or the legacy CADDY_REMOTE_HOST var, set with no local Caddy directory). Resolve the mode the same way configure_caddy_for_service does — explicit CADDY_MODE first, then the local directory, then CADDY_REMOTE_HOST — so caddy_net is only joined when Caddy is actually local. A remote Caddy reaches Traccar via this host's published 8082 port regardless, so no other change is needed for that path. --- services/traccar.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/services/traccar.sh b/services/traccar.sh index 5db6323..e74cf57 100644 --- a/services/traccar.sh +++ b/services/traccar.sh @@ -216,15 +216,22 @@ install_traccar() { local TZ_VAL="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}" + # Mirrors configure_caddy_for_service's own mode resolution (lib/common.sh) + # so this matches whatever Caddy setup the site actually has: an explicit + # CADDY_MODE from the site config wins, then a local ~/docker/caddy, then + # the legacy CADDY_REMOTE_HOST var. Only "local" joins caddy_net — a remote + # Caddy box can't resolve container names on this host's bridge network + # anyway, it reaches Traccar via this host's published 8082 port instead. + local _CADDY_MODE="${CADDY_MODE:-none}" + [ "$_CADDY_MODE" = "none" ] && [ -d "$DOCKER_DIR/caddy" ] && _CADDY_MODE="local" + [ "$_CADDY_MODE" = "none" ] && [ -n "${CADDY_REMOTE_HOST:-}" ] && _CADDY_MODE="remote" + local _CADDY_NET_BLOCK="" - if [ -d "$DOCKER_DIR/caddy" ]; then + local _CADDY_NET_SECTION="" + if [ "$_CADDY_MODE" = "local" ]; then _CADDY_NET_BLOCK=" networks: - caddy_net " - fi - - local _CADDY_NET_SECTION="" - if [ -d "$DOCKER_DIR/caddy" ]; then _CADDY_NET_SECTION=" networks: caddy_net: