đąApprise API web based push notification
Apprise est une librairie Ă©crite en Python et qui vous permet dâenvoyer des notifications (push) Ă la quasi-totalitĂ© des services existant aujourdâhui.
Pour plus dâinformations sur les options de dĂ©ploiement Docker et les configurations de conteneurs avancĂ©es, reportez-vous Ă la section DĂ©ploiement Docker. Pour une configuration systĂšme et des variables dâenvironnement complĂštes, reportez-vous Ă la section Configuration. Pour des exemples dâutilisation dâAPI et des dĂ©tails sur les points de terminaison, reportez-vous Ă API Reference.
Installer Docker et Compose sur Alpine
Sur la VM Alpine
1
2
3
4
5
6
7
8
sudo apk update
sudo apk add docker docker-cli-compose
sudo rc-update add docker default
sudo service docker start
docker version
docker compose version
Apprise
Architecture :
1
2
3
4
5
6
7
8
9
Internet
â HTTPS
âŒ
Serveur Debian
Nginx :443
â HTTP privĂ©
âŒ
VM Alpine
Apprise Docker :8000
Alpine - Préparation répertoires
Connectez-vous en SSH Ă la VM Alpine :
1
2
mkdir -p /opt/apprise/{config,plugin,attach}
chmod -R 755 /opt/apprise
Les répertoires /config, /plugin et /attach permettent de conserver les configurations aprÚs une recréation du conteneur.
Portainer - Créer Stack
Dans Portainer :
- Allez dans Stacks
- Cliquez sur Add stack
- Nom :
apprise - Sélectionnez Web editor
- Collez ce fichier :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
services:
apprise:
image: caronc/apprise:latest
container_name: apprise
ports:
- "8000:8000"
environment:
APPRISE_STATEFUL_MODE: simple
APPRISE_WORKER_COUNT: "1"
APPRISE_DEFAULT_FORMAT: text
APPRISE_AUTH_REQUIRED: "yes"
APPRISE_USER: admin
APPRISE_PASSWORD: "CHANGEZ_CE_MOT_DE_PASSE"
TZ: Europe/Paris
STRICT_MODE: "yes"
volumes:
- /opt/apprise/config:/config
- /opt/apprise/plugin:/plugin
- /opt/apprise/attach:/attach
restart: unless-stopped
security_opt:
- no-new-privileges:true
Modifier
1
APPRISE_PASSWORD: "CHANGEZ_CE_MOT_DE_PASSE"
par un mot de passe fort.
Cliquer sur Deploy the stack.
Les variables APPRISE_AUTH_REQUIRED, APPRISE_USER et APPRISE_PASSWORD activent lâauthentification de lâinterface et de lâAPI. STRICT_MODE permet de limiter les routes acceptĂ©es par le conteneur.
Dans Portainer, pour mettre Apprise Ă jour :
- Ouvrir la Stack
apprise - Cliquer sur Editor
- Cliquer sur Update the stack
- Activer Re-pull image and redeploy
- Valider
Ne supprimez pas /opt/apprise/config, sinon les configurations Apprise seront perdues.
Vérifier le conteneur
Dans Portainer :
- Allez dans Containers
- Ouvrez
apprise - VĂ©rifiez que lâĂ©tat est
running - Consultez Logs en cas de problĂšme
Depuis la VM Alpine , test avec les identifiants
1
2
curl -u 'admin:VOTRE_MOT_DE_PASSE' \
http://127.0.0.1:8000/status
Vous devez obtenir une rĂ©ponse OK. Lâinterface est disponible sur le port 8000.
Depuis le serveur Debian, test
1
2
curl -u 'admin:VOTRE_MOT_DE_PASSE' \
http://IP_DE_LA_VM_ALPINE:8000/status
Debian - Configuration Nginx
Sur le serveur Debian, créez :
1
sudo nano /etc/nginx/conf.d/apprise.rnmkcy.eu.conf
Configuration :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name apprise.rnmkcy.eu;
# Certificats Let's Encrypt
include /etc/nginx/conf.d/ssl-modern.inc;
# Additional security headers (tune as desired)
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options DENY;
add_header X-XSS-Protection "1; mode=block";
#
location / {
proxy_pass http://192.168.0.223:8000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 3600s;
proxy_buffering off;
}
}
Remplacer si besoin
apprise.rnmkcy.eupar votre domaine ;192.168.0.223par lâadresse IP de la VM Alpine.
Vérifier et recharger nginx
1
2
sudo nginx -t
sudo systemctl reload nginx
Nginx doit transmettre les en-tĂȘtes Upgrade et Connection lorsque lâapplication utilise une connexion persistante ou WebSocket.
Proxy nginx + authelia (Facultatif)
Ajouter apprise.rnmkcy.eu dans la configuration authelia access_control:
1
2
3
- domain:
- "apprise.rnmkcy.eu"
policy: two_factor
Relancer authelia
1
sudo systemctl restart authelia
Modifier le fichier apprise.rnmkcy.eu.conf
1
sudo nano /etc/nginx/conf.d/apprise.rnmkcy.eu.conf
Ajouter include snippets/authelia.conf et include snippets/auth.conf;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name apprise.rnmkcy.eu;
include /etc/nginx/conf.d/ssl-modern.inc;
include snippets/authelia.conf;
# Additional security headers (tune as desired)
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options DENY;
add_header X-XSS-Protection "1; mode=block";
#
location / {
proxy_pass http://192.168.0.223:8000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 3600s;
proxy_buffering off;
}
include snippets/auth.conf;
}
Vérifier et recharger NGINX:
1
2
sudo nginx -t
sudo systemctl reload nginx
Bloquer directement lâURL /cfg/ (recommandĂ© si ça ne doit jamais ĂȘtre public)
Dans le server { ⊠} de apprise.rnmkcy.eu, ajouter
1
2
3
location ^~ /cfg/ {
return 403;
}
Alpine port 8000 (FACULTATIF)
La VM Proxmox nâest pas exposĂ© Ă internet
Autoriser uniquement Debian vers port 8000
Le port 8000 ne doit pas ĂȘtre exposĂ© directement sur Internet. Sur Alpine, autorisez uniquement lâIP du serveur Debian.
Avec iptables, par exemple :
1
2
iptables -A INPUT -p tcp -s IP_DU_SERVEUR_DEBIAN --dport 8000 -j ACCEPT
iptables -A INPUT -p tcp --dport 8000 -j DROP
Si le serveur Debian a lâIP 192.168.1.10 :
1
2
iptables -A INPUT -p tcp -s 192.168.1.10 --dport 8000 -j ACCEPT
iptables -A INPUT -p tcp --dport 8000 -j DROP
Apprise web UI
LâAPI inclut un gestionnaire de configuration intĂ©grĂ© Ă https://apprise.rnmkcy.eu

Les configurations sont stockées sous un identifiant de configuration (ou une clé) unique. Choisir un mot clé: yankey

Entrez vos URL (format TEXT ou YAML) et enregistrez-les sur votre clé.
Ici on utilise ntfy

Lancer un test pour envoyer une notification

Vérification sur le serveur ntfy

Speedtest Tracker
Utilisation des notifications via apprise
Notifications problĂšme
Speedtest Tracker peut envoyer des notifications via lâapi apprise

ProblĂšme, il faut dĂ©sactiver lâauthentification de lâapplication
apprise(APPRISE_AUTH_REQUIRED: "no") sinon erreurâŠ
Oui. Le problĂšme est une limitation actuelle de lâintĂ©gration Apprise de Speedtest Tracker : elle ne sait pas envoyer les identifiants Basic Auth Ă Apprise. Une demande de support pour lâauthentification Basic est dâailleurs rĂ©fĂ©rencĂ©e cĂŽtĂ© Speedtest Tracker.
La bonne solution est de laisser Speedtest Tracker appeler /notify sans authentification, mais de restreindre cet endpoint dans Nginx Ă lâadresse IP de Speedtest Tracker.
Solution recommandée avec Nginx
Conservez Apprise avec :
1
APPRISE_AUTH_REQUIRED: "yes"
Dans Nginx, utilisez une route spécifique pour /notify :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
server {
listen 443 ssl;
server_name apprise.rnmkcy.eu;
# Endpoint utilisé par Speedtest Tracker
location = /notify {
allow IP_DU_SERVEUR_SPEEDTEST;
deny all;
proxy_pass http://IP_VM_ALPINE:8000/notify;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 60s;
}
# Interface et autres endpoints Apprise protégés
location / {
auth_basic "Apprise";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://IP_VM_ALPINE:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Remplacez :
1
IP_DU_SERVEUR_SPEEDTEST
par lâadresse IP du serveur qui hĂ©berge Speedtest Tracker, et :
1
IP_VM_ALPINE
par lâadresse IP de la VM Alpine.
Rechargez Nginx :
1
2
sudo nginx -t
sudo systemctl reload nginx
Dans Speedtest Tracker, gardez :
1
2
Apprise Server URL:
https://apprise.rnmkcy.eu/notify
et :
1
2
Service URL:
ntfys://tk_VOTRE_TOKEN@ntfy.rnmkcy.eu/yan_infos?auth=token&priority=default&format=text
Speedtest Tracker utilise actuellement une configuration Apprise sans tags : lâURL doit donc pointer vers /notify et le champ Service URL doit contenir directement lâURL ntfy.
Variante plus simple avec un sous-domaine dédié
Vous pouvez créer un second nom DNS, par exemple :
1
apprise-notify.rnmkcy.eu
Nginx :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
server {
listen 443 ssl;
server_name apprise-notify.rnmkcy.eu;
allow IP_DU_SERVEUR_SPEEDTEST;
deny all;
location /notify {
proxy_pass http://IP_VM_ALPINE:8000/notify;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Dans Speedtest Tracker :
1
https://apprise-notify.rnmkcy.eu/notify
Cette variante sépare clairement :
https://apprise.rnmkcy.eu: interface Apprise protégée ;https://apprise-notify.rnmkcy.eu/notify: endpoint réservé à Speedtest Tracker.
Si Speedtest Tracker et Nginx sont sur des réseaux Docker différents
Nâutilisez pas une adresse Docker interne inaccessible. Testez depuis le conteneur Speedtest Tracker :
1
docker exec -it speedtest-tracker sh
Puis :
1
wget -S -O- https://apprise.rnmkcy.eu/status
Pour /notify, un retour 401 indique que lâauthentification bloque encore Speedtest Tracker ; un retour 403 signifie que lâIP nâest pas autorisĂ©e par Nginx.
La configuration la plus adaptée dans votre cas est donc :
1
APPRISE_AUTH_REQUIRED: "yes"
avec une exception Nginx sans authentification uniquement pour :
1
/notify

