LibrePortal/containers/unbound/scripts/unbound_install_hooks.sh
librelad 614e895b5d fix(unbound): maintained image, and actually recursive this time
mvance/unbound was last rebuilt 668 days ago. Replaced with
madnuttah/unbound (14 days): distroless, runs unprivileged as non-root,
listens on 5335 by default — exactly the "upstream behind a blocker"
shape — and publishes clean semver tags. klutchell/unbound is equally
fresh but defaults to port 53 (fighting Pi-hole/AdGuard for it) and its
tag namespace is CI build soup.

The shipped config was worse than the stale image. It was not a
recursive resolver at all:

    interface: 0.0.0.0@53
    forward-addr: 10.100.0.3@53   # "Local AdGuard" — a hardcoded IP
    forward-addr: 9.9.9.9@853

So it listened on 53 (conflicting with any blocker on the same host),
forwarded to Quad9 — surrendering the "nobody sees my queries" property
that is the only reason to run Unbound in front of a blocker — and
pointed at AdGuard, inverting the dependency: AdGuard should point HERE.

Replaced with a drop-in at conf.d/libreportal.conf. The image's own
unbound.conf ends with `include-toplevel: conf.d/*.conf`, so ours ADDS
to a working recursive config the image author maintains rather than
replacing it — upstream keeps owning the parts that change between
Unbound releases. It contributes access-control (private ranges allow,
everything else REFUSE, so this can never become an open resolver for
amplification attacks), DNSSEC hardening, rebinding protection, and
cache sizing suited to a small VPS. Forwarding is included commented
out, with the trade stated rather than silently chosen.

Ports corrected to 5335:5335 — the old mapping assumed an image
listening on 53 internally. Added the libreportal.category/title labels
the app was missing (no traefik labels: it has no web interface).
Install hook copies the drop-in and repairs a stub directory first, the
same trap that kept Nextcloud's nginx from starting.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 03:51:52 +01:00

27 lines
1.1 KiB
Bash

#!/bin/bash
# Unbound install hooks — place the LibrePortal drop-in config.
#
# The image ships a working recursive unbound.conf that ends with
# include-toplevel: "/usr/local/unbound/conf.d/*.conf"
# so our file is added to it rather than replacing it. Nothing here needs to
# know how to configure a resolver; we contribute access-control, hardening and
# cache sizing, and upstream keeps owning the parts that change between
# Unbound releases.
unbound_install_post_compose()
{
local app_name="$1"
# A previous attempt that started the container before this file existed
# leaves conf.d as a Docker-created stub, and the copy below would then land
# inside it. Same failure that kept Nextcloud's nginx from starting.
repairStubDirForFile "$containers_dir$app_name/conf.d/libreportal.conf" "loud"
local result
result=$(copyResource "$app_name" "libreportal.conf" "conf.d" | runInstallWrite -a "$logs_dir/$docker_log_file" 2>&1)
checkSuccess "Copying libreportal.conf to $containers_dir$app_name/conf.d"
monitoringToggleAppConfig "$app_name" "conf.d/libreportal.conf"
}