Fixed race condition where ja4ebpf would fail to connect to ClickHouse at startup because ClickHouse HTTP port wasn't ready yet, even though Docker healthcheck passed. Changes: - Add 30s wait loop with ClickHouse /ping endpoint check - Log success message when ClickHouse is ready - Applied to all 4 stacks: nginx, apache, nginx-varnish, hitch-varnish Test results after fix: - nginx: 240 rows, 175 JA4 fingerprints ✅ - apache: 257 rows, 191 JA4 fingerprints ✅ - nginx-varnish: 298 rows, 242 JA4 fingerprints ✅ - hitch-varnish: 247 rows, 177 JA4 fingerprints ✅ All L3/L4 metadata (TTL, MSS, Window), TLS fingerprinting (JA4, SNI), and HTTP layer data are correctly captured and persisted. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
43 lines
1.6 KiB
Bash
43 lines
1.6 KiB
Bash
#!/usr/bin/env bash
|
|
# =============================================================================
|
|
# entrypoint.sh — Stack Apache HTTPD + ja4ebpf
|
|
# Démarre Apache en foreground et lance ja4ebpf en arrière-plan.
|
|
# =============================================================================
|
|
set -euo pipefail
|
|
|
|
# Activer le module HTTP/2 si pas déjà chargé
|
|
if ! httpd -M 2>/dev/null | grep -q http2_module; then
|
|
echo "LoadModule http2_module modules/mod_http2.so" >> /etc/httpd/conf.modules.d/00-base.conf
|
|
fi
|
|
|
|
# Créer les répertoires de run nécessaires
|
|
mkdir -p /run/httpd /var/log/httpd
|
|
|
|
# Attendre que ClickHouse soit prêt (connection refused possible sinon)
|
|
echo "[entrypoint] Attente de ClickHouse (max 30s)…"
|
|
for i in $(seq 1 30); do
|
|
if curl -sf http://clickhouse:8123/ping >/dev/null 2>&1; then
|
|
echo "[entrypoint] ClickHouse est prêt (http://clickhouse:8123/ping OK)"
|
|
break
|
|
fi
|
|
if [ $i -eq 30 ]; then
|
|
echo "[entrypoint] ⚠ ClickHouse toujours pas prêt après 30s, démarrage ja4ebpf quand même"
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
# Démarrer ja4ebpf en arrière-plan (optionnel : ne bloque pas le démarrage)
|
|
/usr/local/bin/ja4ebpf -config /etc/ja4ebpf/config.yml &
|
|
JA4_PID=$!
|
|
echo "[entrypoint] ja4ebpf démarré (PID $JA4_PID)"
|
|
|
|
# Laisser 3s pour détecter un échec immédiat (ex: verifier eBPF)
|
|
sleep 3
|
|
if ! kill -0 "$JA4_PID" 2>/dev/null; then
|
|
echo "[entrypoint] ⚠ ja4ebpf s'est arrêté immédiatement — mode dégradé (Apache seul)"
|
|
fi
|
|
|
|
# Démarrer Apache HTTPD en foreground
|
|
echo "[entrypoint] Démarrage d'Apache HTTPD..."
|
|
exec /usr/sbin/httpd -DFOREGROUND
|