root restreinte au socket Fail2ban| Service | Port Externe | Binding Hôte | Isolation / Usage |
|---|---|---|---|
| SSH | 22/TCP |
0.0.0.0 |
Accès restreint Clés SSH publiques |
| Nginx PM | 80, 443/TCP |
0.0.0.0 |
Public Reverse Proxy & Certificats SSL |
| WireGuard | 51821/UDP |
0.0.0.0 |
VPN Tunnel d'administration à distance |
| NPM Admin | 81/TCP |
127.0.0.1, 10.100.42.1 |
Protégé Interface Web (VPN / Local) |
| Vaultwarden | 8080/TCP |
127.0.0.1 |
Isolé Accessible via Nginx PM uniquement |
| pi-api | 8000/TCP |
127.0.0.1 |
Isolé Socket Fail2ban + API système |
pi-apiapp/routers/mon_module.py :
from fastapi import APIRouter
router = APIRouter(prefix="/mon-module", tags=["Mon Module"])
@router.get("/status")
async def get_status():
return {"status": "ok"}
app/main.py :
from app.routers.mon_module import router as mon_module_router
app.include_router(mon_module_router, dependencies=[Depends(verify_api_key)])
cd /home/hua/pi-api && docker compose up -d --build
commands/ma_commande.py :
import os, httpx
from telegram import Update
from telegram.ext import CommandHandler, ContextTypes
from utils.security import restricted
description = "Description de la commande"
API_URL = os.getenv("PI_API_URL", "http://172.17.0.1:8000")
API_KEY = os.getenv("PI_API_KEY", "")
@restricted
async def ma_commande_callback(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
headers = {"X-API-Key": API_KEY}
async with httpx.AsyncClient() as client:
res = await client.get(f"{API_URL}/mon-module/status", headers=headers)
await update.message.reply_text(f"Résultat : {res.json().get('status')}")
handler = CommandHandler("macommande", ma_commande_callback)
cd /home/hua/bot-telegram-command-handler && docker compose up -d --build
/tmp (RAM / tmpfs) pour préserver la MicroSDsqlite3 .backup).tar.gz.gpg chiffrée en AES256/etc/wireguard & PiVPNpi-api et bot-telegram-command-handler/home/hua/.ssh)gpg --batch --yes --decrypt --passphrase "TON_MOT_DE_PASSE" -o infra_backup.tar.gz infra_backup_YYYYMMDD_HHMMSS.tar.gz.gpg
tar -xzf infra_backup.tar.gz && cd backup_YYYYMMDD_HHMMSS/
# Exemple pour Vaultwarden
cp vaultwarden/db.sqlite3 /home/hua/vaultwarden/data/
rsync -az vaultwarden/data_files/ /home/hua/vaultwarden/data/
# Relance des stacks Docker
cd /home/hua/pi-api && docker compose up -d
cd /home/hua/bot-telegram-command-handler && docker compose up -d