Task 4 (Better Jail Configuration) implementation:
- Add fail2ban_config_dir setting to app/config.py
- New file_config_service: list/view/edit/create jail.d, filter.d, action.d files
with path-traversal prevention and 512 KB content size limit
- New file_config router: GET/PUT/POST endpoints for jail files, filter files,
and action files; PUT .../enabled for toggle on/off
- Extend config_service with delete_log_path() and add_log_path()
- Add DELETE /api/config/jails/{name}/logpath and POST /api/config/jails/{name}/logpath
- Extend geo router with re-resolve endpoint; add geo_re_resolve background task
- Update blocklist_service with revised scheduling helpers
- Update Docker compose files with BANGUI_FAIL2BAN_CONFIG_DIR env var and
rw volume mount for the fail2ban config directory
- Frontend: new Jail Files, Filters, Actions tabs in ConfigPage; file editor
with accordion-per-file, editable textarea, save/create; add/delete log paths
- Frontend: types in types/config.ts; API calls in api/config.ts and api/endpoints.ts
- 63 new backend tests (test_file_config_service, test_file_config, test_geo_re_resolve)
- 6 new frontend tests in ConfigPageLogPath.test.tsx
- ruff, mypy --strict, tsc --noEmit, eslint: all clean; 617 backend tests pass
105 lines
3.2 KiB
YAML
105 lines
3.2 KiB
YAML
# ──────────────────────────────────────────────────────────────
|
|
# BanGUI — Production Compose
|
|
#
|
|
# Compatible with:
|
|
# docker compose -f Docker/compose.prod.yml up -d
|
|
# podman compose -f Docker/compose.prod.yml up -d
|
|
# podman-compose -f Docker/compose.prod.yml up -d
|
|
#
|
|
# Prerequisites:
|
|
# Create a .env file at the project root (or pass --env-file):
|
|
# BANGUI_SESSION_SECRET=<random-secret>
|
|
# ──────────────────────────────────────────────────────────────
|
|
|
|
name: bangui
|
|
|
|
services:
|
|
# ── fail2ban ─────────────────────────────────────────────────
|
|
fail2ban:
|
|
image: lscr.io/linuxserver/fail2ban:latest
|
|
container_name: bangui-fail2ban
|
|
restart: unless-stopped
|
|
cap_add:
|
|
- NET_ADMIN
|
|
- NET_RAW
|
|
network_mode: host
|
|
environment:
|
|
TZ: "${BANGUI_TIMEZONE:-UTC}"
|
|
PUID: 0
|
|
PGID: 0
|
|
volumes:
|
|
- fail2ban-config:/config
|
|
- fail2ban-run:/var/run/fail2ban
|
|
- /var/log:/var/log:ro
|
|
healthcheck:
|
|
test: ["CMD", "fail2ban-client", "ping"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
start_period: 15s
|
|
retries: 3
|
|
|
|
# ── Backend (FastAPI + uvicorn) ─────────────────────────────
|
|
backend:
|
|
build:
|
|
context: ..
|
|
dockerfile: Docker/Dockerfile.backend
|
|
container_name: bangui-backend
|
|
restart: unless-stopped
|
|
depends_on:
|
|
fail2ban:
|
|
condition: service_healthy
|
|
environment:
|
|
BANGUI_DATABASE_PATH: "/data/bangui.db"
|
|
BANGUI_FAIL2BAN_SOCKET: "/var/run/fail2ban/fail2ban.sock"
|
|
BANGUI_FAIL2BAN_CONFIG_DIR: "/config/fail2ban"
|
|
BANGUI_LOG_LEVEL: "info"
|
|
BANGUI_SESSION_SECRET: "${BANGUI_SESSION_SECRET:?Set BANGUI_SESSION_SECRET}"
|
|
BANGUI_TIMEZONE: "${BANGUI_TIMEZONE:-UTC}"
|
|
volumes:
|
|
- bangui-data:/data
|
|
- fail2ban-run:/var/run/fail2ban:ro
|
|
- fail2ban-config:/config:rw
|
|
expose:
|
|
- "8000"
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health')"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
start_period: 10s
|
|
retries: 3
|
|
networks:
|
|
- bangui-net
|
|
|
|
# ── Frontend (nginx serving built SPA + API proxy) ──────────
|
|
frontend:
|
|
build:
|
|
context: ..
|
|
dockerfile: Docker/Dockerfile.frontend
|
|
container_name: bangui-frontend
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${BANGUI_PORT:-8080}:80"
|
|
depends_on:
|
|
backend:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-qO", "/dev/null", "http://localhost:80/"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
start_period: 5s
|
|
retries: 3
|
|
networks:
|
|
- bangui-net
|
|
|
|
volumes:
|
|
bangui-data:
|
|
driver: local
|
|
fail2ban-config:
|
|
driver: local
|
|
fail2ban-run:
|
|
driver: local
|
|
|
|
networks:
|
|
bangui-net:
|
|
driver: bridge
|