Fix Caddy routing: use container:port via caddy_net (DoTheEvo pattern)
Undo the host.docker.internal approach from the previous commit — proper Docker networking routes Caddy to services by container name on the shared caddy_net, not via the host gateway. - lib/common.sh: configure_caddy_for_service now accepts either a plain port number (localhost:PORT fallback) or container:port (preferred). The Caddyfile entry uses the container name for direct Docker DNS routing. - services/caddy.sh: remove extra_hosts hack; update Caddyfile template comments to show container_name:port format - All service files: update configure_caddy_for_service calls to pass container_name:internal_port (e.g. "filebrowser:80", "mealie:9000"). Services using network_mode:host keep plain port numbers. - tools/manage_users.sh: new FileBrowser user-management script (deployed to ~/docker/filebrowser/ during installation). Manages users via the FileBrowser REST API: list, add, delete, passwd, scope, info commands. Documents username format (letters/numbers/hyphens/underscores), password rules (min 8 chars, letter + number required), and scope path convention relative to /srv (= FB_PATH on the host). https://claude.ai/code/session_01UZus2Q9gNTfUdqSMrhuX29
This commit is contained in:
+15
-4
@@ -261,9 +261,20 @@ write_readme() {
|
||||
}
|
||||
|
||||
# ── Caddy reverse-proxy wiring (shared by every web service) ─────────────────
|
||||
# Usage: configure_caddy_for_service "Name" "PORT" "default-subdomain" ["extra"]
|
||||
# Usage: configure_caddy_for_service "Name" "UPSTREAM" "default-subdomain" ["extra"]
|
||||
# UPSTREAM: container:port for caddy_net routing (e.g. "filebrowser:80"),
|
||||
# or plain port number for localhost fallback (e.g. "8085").
|
||||
configure_caddy_for_service() {
|
||||
local SERVICE_NAME="$1" SERVICE_PORT="$2" DEFAULT_SUBDOMAIN="$3" EXTRA_CONFIG="${4:-}"
|
||||
local SERVICE_NAME="$1" SERVICE_UPSTREAM="$2" DEFAULT_SUBDOMAIN="$3" EXTRA_CONFIG="${4:-}"
|
||||
|
||||
# Derive the proxy upstream and a port number for display messages.
|
||||
# Plain number → localhost:PORT (host-network or legacy services)
|
||||
# name:port → used as-is (preferred: service on shared caddy_net)
|
||||
local _UPSTREAM _DISPLAY_PORT
|
||||
case "$SERVICE_UPSTREAM" in
|
||||
*:*) _UPSTREAM="$SERVICE_UPSTREAM"; _DISPLAY_PORT="${SERVICE_UPSTREAM##*:}" ;;
|
||||
*) _UPSTREAM="localhost:$SERVICE_UPSTREAM"; _DISPLAY_PORT="$SERVICE_UPSTREAM" ;;
|
||||
esac
|
||||
|
||||
# Caddy not installed → nothing to do
|
||||
[ -d "$DOCKER_DIR/caddy" ] || return 0
|
||||
@@ -280,7 +291,7 @@ configure_caddy_for_service() {
|
||||
prompt_yn "Configure Caddy reverse proxy for $SERVICE_NAME? (y/n):" "n" CONFIGURE_CADDY
|
||||
if [ "$CONFIGURE_CADDY" != "y" ] && [ "$CONFIGURE_CADDY" != "Y" ]; then
|
||||
echo " Skipping Caddy configuration."
|
||||
echo " Access $SERVICE_NAME at: http://localhost:$SERVICE_PORT"
|
||||
echo " Access $SERVICE_NAME at: http://localhost:$_DISPLAY_PORT"
|
||||
return 0
|
||||
fi
|
||||
|
||||
@@ -320,7 +331,7 @@ configure_caddy_for_service() {
|
||||
|
||||
# $SERVICE_NAME
|
||||
$SERVICE_DOMAIN {
|
||||
reverse_proxy host.docker.internal:$SERVICE_PORT
|
||||
reverse_proxy $_UPSTREAM
|
||||
|
||||
# Security headers
|
||||
header {
|
||||
|
||||
Reference in New Issue
Block a user