This commit is contained in:
Christoph K.
2026-03-11 16:26:11 +01:00
commit 402395c856
9 changed files with 236 additions and 0 deletions

93
mosquitto/README.md Normal file
View File

@@ -0,0 +1,93 @@
# mqtt-emma
Eclipse Mosquitto MQTT broker als Docker Compose Stack für Synology NAS.
## Voraussetzungen
- Synology NAS mit Docker/Container Manager
- SSH-Zugriff auf die NAS
- `docker` und `docker compose` verfügbar (ab DSM 7.2 inklusive)
## Deployment
### 1. Dateien auf die NAS kopieren
```bash
scp -r mqtt-emma/ admin@192.168.1.4:/volume1/docker/mqtt-emma
```
Oder per File Station / SMB-Share auf die NAS kopieren.
### 2. Per SSH einloggen und ins Projektverzeichnis wechseln
```bash
ssh admin@192.168.1.4
cd /volume1/docker/mqtt-emma
```
### 3. Stack starten
```bash
docker compose up -d
```
### 4. Verbindung testen
Von einem Rechner im gleichen Netzwerk (mosquitto-clients erforderlich):
```bash
# Subscriber starten
mosquitto_sub -h 192.168.1.4 -p 1883 -t 'test/#' -v
# In einem zweiten Terminal: Nachricht senden
mosquitto_pub -h 192.168.1.4 -p 1883 -t 'test/hello' -m 'welt'
```
> **Hinweis:** Aktuell ist anonymer Zugriff aktiviert (kein Passwort nötig). Für Produktion `allow_anonymous false` und `password_file` in `mosquitto/config/mosquitto.conf` einkommentieren.
## Ports
| Port | Protokoll | Beschreibung |
|------|------------|-----------------------------------|
| 1883 | MQTT | Standard MQTT |
| 9001 | WebSockets | Für Browser-Clients (z. B. MQTT.js) |
## Nützliche Befehle
```bash
# Logs anzeigen
docker compose logs -f mosquitto
# Stack stoppen
docker compose down
# Config neu laden (ohne Neustart)
docker compose kill -s HUP mosquitto
# Broker-Status prüfen
docker compose ps
```
## Konfiguration
Die Broker-Konfiguration liegt in `mosquitto/config/mosquitto.conf`.
Nach Änderungen genügt ein Config-Reload:
```bash
docker compose kill -s HUP mosquitto
```
Für Änderungen an Ports oder Volumes ist ein Neustart nötig:
```bash
docker compose down && docker compose up -d
```
## Zeitzone anpassen
In `docker-compose.yml` die Umgebungsvariable `TZ` anpassen, z. B.:
```yaml
environment:
- TZ=Europe/Vienna
```

View File

@@ -0,0 +1,28 @@
# Mosquitto MQTT Broker Configuration
# Persistence
persistence true
persistence_location /mosquitto/data/
# Logging
log_dest file /mosquitto/log/mosquitto.log
log_dest stdout
log_type error
log_type warning
log_type notice
log_type information
# MQTT Listener (plain)
listener 1883
protocol mqtt
# WebSocket Listener
listener 9001
protocol websockets
# Authentication
# Für lokale Tests: anonym erlaubt, kein Passwort nötig
allow_anonymous true
# Für Produktion: anonym deaktivieren und passwd-Datei einbinden
# allow_anonymous false
# password_file /mosquitto/config/passwd

View File

@@ -0,0 +1,14 @@
services:
mosquitto:
image: eclipse-mosquitto:latest
container_name: mqtt-emma
restart: unless-stopped
ports:
- "1883:1883" # MQTT
- "9001:9001" # WebSocket
volumes:
- ./mosquitto/config:/mosquitto/config
- ./mosquitto/data:/mosquitto/data
- ./mosquitto/log:/mosquitto/log
environment:
- TZ=Europe/Berlin