Forward ntfy messages to configurable targets (Telegram / Discord / Slack / generic webhook) with:
- Web UI
- Topic-to-target routing
- Queue, retry, dead-letter queue (DLQ)
- Error history and exports
- Prometheus metrics
This project is now UI-driven for runtime config:
- Topics are managed in the app
- Targets are managed in the app
- Queue/behavior/performance/summary settings are managed in the app
No environment variables are used anymore for topics/targets/settings categories.
services:
forwarder:
build: .
image: ntfy-forwarder:local
ports:
- "8081:8081"
volumes:
- forwarder_data:/app/data
environment:
NTFY_BASE_URL: "http://ntfy"
ACCESS_TOKEN: "change-me"
TZ: "Europe/Paris"
LOG_LEVEL: "INFO"
# Optional OIDC
# OIDC_ENABLED: "true"
# OIDC_ISSUER_URL: "https://sso.example.com/application/o/forwarder/"
# OIDC_CLIENT_ID: "ntfy-forwarder"
# OIDC_CLIENT_SECRET: "..."
# OIDC_REDIRECT_URI: "https://forwarder.example.com/auth/callback"
# OIDC_SESSION_SECRET: "change-me-long-random-secret"
# Optional local login
# ACCESS_LOCAL_ENABLED: "true"
# ACCESS_LOCAL_USERNAME: "admin"
# ACCESS_LOCAL_PASSWORD: "change-me"
volumes:
forwarder_data:Set NTFY_BASE_URL to a reachable ntfy server; the example assumes a service
named ntfy on the same Docker network. Run docker compose up --build -d and
open http://localhost:8081/?token=change-me using your own private access token.
Then:
- Open
/targetsand create at least one target. - Mark one target as default.
- Open
/and assign per-topic targets if needed. - Open
/settingsto tune runtime behavior.
Supported target kinds:
telegramwebhook_discordwebhook_slackwebhook_generic
Target configs:
telegram:chat_id,bot_token,max_message_lengthwebhook_*:url, optionalauth_header
Routing behavior:
- If a topic has a linked target, it is used.
- Otherwise the default target is used.
All of these are configured from /settings:
- Retry / queue
- Behavior
- Performance / maintenance
- Aggregation / digest / summary
NTFY_BASE_URL(default:http://ntfy)NTFY_TOKEN(optional)DB_PATH(default:/app/data/ntfy.db)EXPORT_DIR(default:exportsbesideDB_PATH)BACKUP_DIR(default:backupsbesideDB_PATH)TZ(default:UTC)LOG_LEVEL(default:INFO)
ACCESS_TOKEN(optional)ACCESS_ALLOW_QUERY_TOKEN(default:true)ACCESS_SESSION_SECRET(optional, fallback:OIDC_SESSION_SECRET)
OIDC_ENABLED(default:false)OIDC_ISSUER_URLOIDC_CLIENT_IDOIDC_CLIENT_SECRETOIDC_REDIRECT_URIOIDC_SESSION_SECRETOIDC_SESSION_TTL_SECONDS(default:86400)OIDC_STATE_TTL_SECONDS(default:300)OIDC_CLOCK_SKEW_SECONDS(default:60)OIDC_SCOPES(default:openid profile email)OIDC_ALLOWED_EMAILS(optional)OIDC_ALLOWED_DOMAINS(optional)OIDC_VERIFY_TLS(default:true)OIDC_REQUIRE_VERIFIED_EMAIL(default:false)OIDC_LOGIN_TEXT(default:Login with SSO)OIDC_LOGIN_ICON(default:bi-shield-lock)
ACCESS_LOCAL_ENABLED(default:false)ACCESS_LOCAL_USERNAMEACCESS_LOCAL_PASSWORDACCESS_LOCAL_SESSION_TTL_SECONDS(default:86400)
GET /GET /topic/{name}GET /statsGET /errorsGET /queueGET /targetsGET /settingsGET /loginGET /logoutGET /auth/loginGET /auth/callbackGET /auth/logout
GET /healthGET /metrics
GET /api/topicsGET /api/topics/{name}POST /api/topics/{name}/togglePOST /api/topics/{name}/targetPOST /api/topics/{name}/clearPOST /api/topics/{name}/reset_countPOST /api/topics/clear_allPOST /api/topics/hard_clear_allPOST /api/topics/pause_allPOST /api/topics/resume_allGET /api/topics/exportPOST /api/topics/import
GET /api/targetsPOST /api/targetsPUT /api/targets/{id}DELETE /api/targets/{id}POST /api/targets/{id}/default
GET /api/settingsPOST /api/settings
GET /api/statsGET /api/errors?q=...&offset=0&limit=100&format=csvPOST /api/errors/clearGET /api/queue/dead_letters?q=...&offset=0&limit=100POST /api/queue/dead_letters/{id}/requeuePOST /api/queue/dead_letters/{id}/deletePOST /api/queue/dead_letters/requeue_batchPOST /api/queue/dead_letters/clear
- Prefer cookie/header auth over query token in public environments (
ACCESS_ALLOW_QUERY_TOKEN=false). - Keep
OIDC_VERIFY_TLS=truein production. - Restrict OIDC access with
OIDC_ALLOWED_EMAILSorOIDC_ALLOWED_DOMAINS.
- Grafana dashboard:
observability/grafana-dashboard.json - Prometheus alerts:
observability/prometheus-alerts.yml
Requires Python 3.12 or newer.
python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt -r requirements-dev.txt
pytest -q --cov --cov-report=term-missing --cov-report=html --cov-report=xml
flake8 --jobs 1 .Coverage includes all application modules and branches; .coveragerc enforces
100% coverage. Open htmlcov/index.html for per-file results. CI runs the same
check and publishes the HTML/XML reports. Tests use temporary SQLite databases,
the real aiosqlite driver, local HTTP servers and RSA-signed OIDC tokens.
They require no external Telegram account or ntfy server.
For local use, set DB_PATH to a writable path, for example:
DB_PATH=./data/ntfy.db ACCESS_TOKEN=your-token NTFY_BASE_URL=http://localhost:8080 python app.py- Configure an enabled default target, or a target for each topic. Missing destinations trigger retries and eventual preservation in the dead-letter queue.
- Runtime behavior uses Settings in SQLite. Equal quiet-hours boundaries disable
filtering; defaults filter priorities below 4 between 23:00 and 07:00 in
TZ. The default aggregation interval is 30 seconds. - Errors shows failures; Queue lets you inspect and requeue dead letters. Requeue preserves the topic, title and attachment of raw messages received while a topic was disabled.
/healthreturns HTTP 503 if SQLite is unavailable and reports stale workers and destination failures in its JSON. Docker runshealthcheck.shautomatically.- SQLite is the authoritative delivery queue. Moves to/from the dead-letter queue are transactional. Graceful shutdown flushes partial reception/aggregation buffers.
- Queued delivery is at least once: a crash after acceptance by a destination but before acknowledgment commits may cause a duplicate. Reception/aggregation buffers remain in memory; forced termination before enqueue can lose buffered events. ntfy cache replay across restarts is not implemented.
- Backups use SQLite's online backup API and include committed WAL data, producing
.dband.db.gzfiles inBACKUP_DIR.