Owner run: the CLI prints 'All services bind to 0.0.0.0' and ignored the rootless daemon's default address; the gateway could not share 54321/54324 with 0.0.0.0 listeners. Now: Kong serves the API directly; the DEV gateway serves only Mailpit with basic auth on <DEV host>:54325; ENVIRONMENTS.md §3 gives the exact UFW rules (interface-scoped deny on 54322-54324, two cases by current UFW state), rollback and impact; dev:net-check proves the allowed surfaces from a distinct Docker network (5/5 OK) and prints the refusal checks to run from another device, since a rootless container's traffic to the host is delivered locally and cannot see the LAN firewall. LRN-053 corrects LRN-052.
63 lines
3.1 KiB
Bash
Executable File
63 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Access check of the DEV surfaces (docs/development/ENVIRONMENTS.md §3.3).
|
|
# pnpm dev:net-check # expects the stack, pnpm dev and the gateway running
|
|
# Part 1 probes the ALLOWED surfaces from a throwaway container on its own Docker network,
|
|
# which reaches the host by its LAN address only. Part 2 cannot be proven from this machine:
|
|
# with Docker rootless a container's traffic to the host's own address is delivered
|
|
# locally, never through the LAN interface, so the firewall rules that close 54322-54324
|
|
# on that interface are invisible here. It prints the commands to run on another device.
|
|
# Exit 1 when an allowed surface fails.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
. scripts/dev-env.sh
|
|
host="$FAUNOSTEO_DEV_HOST"
|
|
net=faunosteo_net_check
|
|
image=curlimages/curl:8.11.1
|
|
docker network create "$net" >/dev/null 2>&1 || true
|
|
# shellcheck disable=SC2329 # invoked by the trap
|
|
cleanup() { docker network rm "$net" >/dev/null 2>&1 || true; }
|
|
trap cleanup EXIT
|
|
|
|
failed=0
|
|
probe() { # probe <label> <expected HTTP code> <curl args...>
|
|
local label="$1" expected="$2"; shift 2
|
|
local code status=0
|
|
code="$(docker run --rm --network "$net" "$image" -s -o /dev/null -w '%{http_code}' --connect-timeout 4 "$@" 2>/dev/null)" || status=$?
|
|
# curl exit 7 = refused, 28 = timeout: nothing answers; other non-zero = a non-HTTP service.
|
|
case "$status" in 0) ;; 7|28) code=closed ;; *) code=open ;; esac
|
|
if [ "$code" = "$expected" ]; then
|
|
printf 'OK %-50s %s\n' "$label" "$code"
|
|
else
|
|
printf 'FAIL %-50s %s (expected %s)\n' "$label" "$code" "$expected"
|
|
failed=1
|
|
fi
|
|
}
|
|
|
|
password=""
|
|
[ -s docker/dev-gateway/mailpit-password ] && password="$(cat docker/dev-gateway/mailpit-password)"
|
|
echo "== 1. allowed surfaces, from a separate Docker network towards $host"
|
|
probe "app :5173 (Vite)" 200 "http://$host:5173/login"
|
|
probe "Supabase API :54321 auth health" 200 "http://$host:54321/auth/v1/health"
|
|
probe "Supabase API :54321 REST without key" 401 "http://$host:54321/rest/v1/profiles"
|
|
probe "Mailpit gateway :54325 without credentials" 401 "http://$host:54325/"
|
|
if [ -n "$password" ]; then
|
|
probe "Mailpit gateway :54325 with credentials" 200 -u "dev:$password" "http://$host:54325/"
|
|
else
|
|
echo "SKIP Mailpit gateway with credentials (run pnpm dev:gateway first)"
|
|
fi
|
|
|
|
echo "== 2. refused surfaces: run on ANOTHER device of the network (this machine cannot see its LAN firewall)"
|
|
cat <<EOF
|
|
nc -zv -w 3 $host 54322 # PostgreSQL -> must fail (timeout or refused)
|
|
nc -zv -w 3 $host 54323 # Studio -> must fail
|
|
nc -zv -w 3 $host 54324 # raw Mailpit -> must fail
|
|
nc -zv -w 3 $host 54321 # Supabase API -> must succeed (control)
|
|
(phone: http://$host:54323 must not load; http://$host:5173 must)
|
|
EOF
|
|
|
|
echo "== 3. listeners published by the stack (the CLI forces 0.0.0.0; the firewall closes 54322-54324 on the LAN)"
|
|
for c in supabase_kong_faunosteo supabase_db_faunosteo supabase_studio_faunosteo supabase_inbucket_faunosteo faunosteo_dev_gateway; do
|
|
printf ' %-30s %s\n' "$c" "$(docker port "$c" 2>/dev/null | grep -v '::' | tr '\n' ' ')"
|
|
done
|
|
exit "$failed"
|