Fix the proxy trust test and the conffile prompt that published a broken layer #1
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Keel-Linux/keel-nodebb!1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/proxy-trust"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Two fixes found on the live forum on 2026-09-26, carried into the sources,
plus the tests that keep them from coming back.
1. The trusted proxy was tested against the wrong address
/etc/nginx/conf.d/nodebb-proxy.conf, written at first boot byfirstboot.d/40nodebb, declaredgeo $nodebb_trusted_proxy, which reads$remote_addr. The same file setsset_real_ip_fromwithreal_ip_header X-Forwarded-For, and the realip module runs in the post readphase, before any geo or map variable is evaluated. By the time the trust
test ran,
$remote_addralready held the address the proxy had put inX-Forwarded-For: the visitor, not the proxy. The geo block never matched,$nodebb_schemestayedhttp, and every request to port 80 was answeredwith a 307 to https, which the TLS terminating proxy sent straight back.
Fixed by matching on
$realip_remote_addr, which keeps the address theconnection really came from. The rendered file and the shipped default both
carry a comment explaining the trap.
Reproduced and verified on a second container (
forum2) assembled from thelayer of 2026-09-26, from the public services VM, over IPv6:
X-Forwarded-Forpresent,X-Forwarded-Proto: https<title>Home | NodeBB</title>X-Forwarded-ForThe second row is why this went unnoticed: without
X-Forwarded-Fortherealip module does nothing and the old geo block happened to work.
2. The build published a half configured layer
The overlay ships
/etc/confconsole/services.txt, a conffile of confconsole,so the explicit upgrade of inithooks and confconsole added in
f9ee052met adpkg conffile prompt. Conf scripts run with stdin closed, dpkg read end of
file at the prompt and left confconsole
install ok unpacked, apt exited 100and
root.patchedfailed.The build failing was not the problem.
bt-layerpacks and exports whateverroot.patchedleft behind even when make fails (... | tee -a "$log" || true),and because the target never finished, fab never removed the build overlays.
The layer published on 2026-09-26 (sha256
40e3f4da) therefore carries/usr/local/bin/systemctland/usr/local/bin/service, the build timechroot shims, which
coreandnodejs-nginxdo not have. At the first boot10regen-sshkeyslooped on them forever.Fixed here by keeping the overlay's conffile non interactively and by
checking the dpkg state as well as the version, since a half configured
package reports the new version either way. The
bt-layerhalf is abuildtasks change and is not in this pull request.
Tests
tests/hook.bats, 15 tests: the hook runs for real against scratchdirectories with PATH stubs for
systemctl,nginx,redis-cli,chownand
runuserand a fake./nodebb. Setup call,config.jsonpatch, proxyconf rendering,
nginx -t, service calls, asset build switch, bothidempotence paths, bad and empty
APP_TRUSTED_PROXY, domain fallback,missing password with and without a terminal.
tests/nginx.bats, 12 tests: the shipped conf.d default and the renderedfile agree on the geo variable and the map, the site file and the shared
proxy include.
tests/nodebb.bats, 26 tests: the library, including an assertion that thegeo block uses
$realip_remote_addrand that neithergeo $remote_addrnor the old
geo $nodebb_trusted_proxyis present.tests/coverage.shnow runs the whole suite and measures the hook as wellas the library.
Coverage (decision 0003, 95 percent on project authored code)
The one uncovered line is inside the dialog loop, which needs a terminal; the
test that drives it through
script(1)covers the rest of the branch.Test plan
bats tests/on the workstation: 53 tests, all passingtests/coverage.sh: both files above 95 percentsh -nand shellcheck on the changed shellforum2from the layer, driven by the inithooks chainalone:
00declarativeread/etc/keel/instance.yaml, wrote/etc/inithooks.conf, 20 hooks completed, nodebb, nginx and redisactive,
keel diffreports the four known driftsbuild host's product tree
shell / coveragepassed in 2m2s: 100.00 percent on lib/nodebb.sh (43/43) and 96.97 percent on firstboot.d/40nodebb (32/33), both above the 95 percent bar of decision 0003.tests / build-and-bootcannot run and is not being waited for. It targets the self-hosted runnerkeel-lxc-1, which is online and idle, but the organization's Default runner group hasallows_public_repositories: falseand this repository is public, so the job stays queued until GitHub cancels it after 24 hours. Two other things would stop it even then: that runner has no fab or buildtasks (docs/releases-host.md section 7), and the recipe change here needs a layer rebuild on the build host. The appliance was instead validated by hand on the build host, in a second container assembled from the layer of 2026-09-26; the results are in the description and in docs/forum-build-2026-09-26.md.