b968ec8aa5
Reverse proxy Nginx (image stable-alpine) qui sert l'app upstream ou une page de maintenance 503 selon l'IP du client. - Modes whitelist/blacklist commutables via MAINTENANCE_MODE - Liste IPv4 via MAINTENANCE_IP_LIST (séparée par virgules, validée au boot) - Logique en directives Nginx natives (geo + map), zéro Lua/njs - Page statique sobre HTML+CSS inline, zéro JS, zéro réseau sortant - Log dédié /var/log/nginx/maintenance.log pour les requêtes bloquées - Validation des env vars dans /docker-entrypoint.d/10-init.sh - Stack Docker + docker-compose pour dev local et tests - 6 cas de tests d'intégration (whitelist/blacklist x autorisée/bloquée + log + nginx -t) - Lint shellcheck propre sur tous les scripts shell
48 lines
1.3 KiB
Bash
Executable File
48 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Vérifie la qualité du projet :
|
|
# 1. shellcheck sur tous les scripts shell.
|
|
# 2. nginx -t sur la conf templatée (via un conteneur jetable).
|
|
|
|
set -euo pipefail
|
|
|
|
PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$PROJECT_ROOT"
|
|
|
|
shell_files=(
|
|
scripts/build-ip-list.sh
|
|
scripts/entrypoint.sh
|
|
scripts/lint.sh
|
|
tests/run.sh
|
|
tests/lib.sh
|
|
tests/cases/whitelist_authorized_ip.sh
|
|
tests/cases/whitelist_unauthorized_ip.sh
|
|
tests/cases/blacklist_blocked_ip.sh
|
|
tests/cases/blacklist_normal_ip.sh
|
|
tests/cases/log_dedicated.sh
|
|
tests/cases/nginx_syntax.sh
|
|
)
|
|
|
|
echo "==> shellcheck"
|
|
if command -v shellcheck >/dev/null 2>&1; then
|
|
shellcheck -x "${shell_files[@]}"
|
|
else
|
|
# Fallback : shellcheck via Docker si l'outil n'est pas installé localement.
|
|
docker run --rm -v "$PROJECT_ROOT:/mnt" -w /mnt koalaman/shellcheck:stable -x "${shell_files[@]}"
|
|
fi
|
|
echo "shellcheck OK"
|
|
|
|
echo "==> nginx -t (build d'image + check)"
|
|
docker build --quiet -t maintenance-proxy:lint . >/dev/null
|
|
|
|
docker run --rm \
|
|
-e MAINTENANCE_MODE=whitelist \
|
|
-e MAINTENANCE_IP_LIST="1.2.3.4,5.6.7.8" \
|
|
-e UPSTREAM_HOST="upstream:80" \
|
|
-e LISTEN_PORT=8080 \
|
|
-e SERVER_NAME=_ \
|
|
--entrypoint /bin/sh \
|
|
maintenance-proxy:lint \
|
|
-c '/docker-entrypoint.sh nginx -t'
|
|
echo "nginx -t OK"
|