Fixed findings
This commit is contained in:
60
README.md
60
README.md
@@ -9,7 +9,7 @@ Komplettes MQTT Setup mit Eclipse Mosquitto Broker und MQTTUI Web Dashboard.
|
||||
- WebSocket auf Port 9001
|
||||
- Passwort-Authentifizierung
|
||||
- ACL (Access Control Lists)
|
||||
- Öffentliches Topic ohne Anmeldung (`public/*`)
|
||||
- Öffentliches Read-Only Topic ohne Anmeldung (`public/*`)
|
||||
- Persistenz aktiviert
|
||||
|
||||
✅ **Web Dashboard (MQTTUI)**
|
||||
@@ -25,6 +25,7 @@ mqtt/
|
||||
├── config/ # Konfigurationsdateien
|
||||
│ ├── mosquitto.conf # Mosquitto Hauptkonfiguration
|
||||
│ ├── acl.conf # Access Control Lists
|
||||
│ ├── passwords.txt.template # Platzhalter zum Bootstrap
|
||||
│ └── passwords.txt # User/Passwort Datei (wird generiert)
|
||||
├── data/ # Mosquitto Persistenz Daten
|
||||
├── log/ # Mosquitto Log-Dateien
|
||||
@@ -52,9 +53,20 @@ cp .env.example .env
|
||||
nano .env
|
||||
```
|
||||
|
||||
> `UID` und `GID` in der `.env` bestimmen jetzt den User, unter dem der Mosquitto-Container läuft. Passe die Werte an deinen Host-User an, falls du nicht `1000:1000` bist.
|
||||
|
||||
⚠️ **WICHTIG**: Setze sichere Passwörter in der `.env` Datei!
|
||||
|
||||
### 2. Server starten
|
||||
### 2. Passwort-Datei vorbereiten
|
||||
|
||||
```bash
|
||||
# Platzhalter kopieren, damit der Container starten kann
|
||||
cp config/passwords.txt.template config/passwords.txt
|
||||
```
|
||||
|
||||
> Das Setup-Script erstellt die Datei bei Bedarf automatisch. Wenn du manuell startest, führe den Kopier-Befehl einmalig aus.
|
||||
|
||||
### 3. Server starten
|
||||
|
||||
```bash
|
||||
# Container starten
|
||||
@@ -64,7 +76,7 @@ docker compose up -d
|
||||
docker compose logs -f
|
||||
```
|
||||
|
||||
### 3. Benutzer erstellen
|
||||
### 4. Benutzer erstellen
|
||||
|
||||
```bash
|
||||
# Setup-Script ausführbar machen
|
||||
@@ -95,7 +107,7 @@ Das Script erstellt folgende User (Credentials aus .env):
|
||||
|
||||
Ohne ACL-Eintrag hat der neue User keine Zugriffsrechte!
|
||||
|
||||
### 4. Dashboard öffnen
|
||||
### 5. Dashboard öffnen
|
||||
|
||||
Web Dashboard: **http://localhost:5000**
|
||||
|
||||
@@ -107,17 +119,16 @@ Web Dashboard: **http://localhost:5000**
|
||||
- **WebSocket**: `ws://localhost:9001`
|
||||
- **Web Dashboard**: `http://localhost:5000`
|
||||
|
||||
### Öffentliches Topic (ohne Anmeldung)
|
||||
### Öffentliche Topics (ohne Anmeldung, read-only)
|
||||
|
||||
Topic: `public/*`
|
||||
|
||||
**Beispiel mit mosquitto_pub:**
|
||||
```bash
|
||||
# Nachricht an öffentliches Topic senden (KEINE Authentifizierung)
|
||||
docker exec mosquitto mosquitto_pub -h localhost -t "public/test" -m "Hallo Welt!"
|
||||
# Öffentliches Topic abhören (keine Auth nötig)
|
||||
docker compose exec -T mosquitto mosquitto_sub -h localhost -t "public/#" -v
|
||||
|
||||
# Öffentliches Topic abhören
|
||||
docker exec mosquitto mosquitto_sub -h localhost -t "public/#" -v
|
||||
# Zum Publishen sind Credentials erforderlich, z.B. Admin:
|
||||
docker compose exec -T mosquitto mosquitto_pub -h localhost -t "public/test" -m "Hallo Welt" -u admin -P <ADMIN_PASSWORD>
|
||||
```
|
||||
|
||||
### Mit Authentifizierung
|
||||
@@ -125,10 +136,10 @@ docker exec mosquitto mosquitto_sub -h localhost -t "public/#" -v
|
||||
**Beispiel mit Admin User:**
|
||||
```bash
|
||||
# Mit Authentifizierung publishen (Credentials aus .env verwenden)
|
||||
docker exec mosquitto mosquitto_pub -h localhost -t "devices/device1/status" -m "online" -u admin -P <ADMIN_PASSWORD>
|
||||
docker compose exec -T mosquitto mosquitto_pub -h localhost -t "devices/device1/status" -m "online" -u admin -P <ADMIN_PASSWORD>
|
||||
|
||||
# Mit Authentifizierung subscriben (Credentials aus .env verwenden)
|
||||
docker exec mosquitto mosquitto_sub -h localhost -t "#" -v -u admin -P <ADMIN_PASSWORD>
|
||||
docker compose exec -T mosquitto mosquitto_sub -h localhost -t "#" -v -u admin -P <ADMIN_PASSWORD>
|
||||
```
|
||||
|
||||
💡 **Hinweis**: Ersetze `<ADMIN_PASSWORD>` mit dem Passwort aus deiner `.env` Datei.
|
||||
@@ -151,7 +162,7 @@ docker compose restart mosquitto
|
||||
**Alternativ - Manuell:**
|
||||
```bash
|
||||
# User hinzufügen/ändern
|
||||
docker exec -it mosquitto mosquitto_passwd -b /mosquitto/config/passwords.txt USERNAME PASSWORD
|
||||
docker compose exec -T mosquitto mosquitto_passwd -b /mosquitto/config/passwords.txt USERNAME PASSWORD
|
||||
|
||||
# ACL in config/acl.conf anpassen und Container neu starten
|
||||
docker compose restart mosquitto
|
||||
@@ -160,7 +171,7 @@ docker compose restart mosquitto
|
||||
### User löschen
|
||||
|
||||
```bash
|
||||
docker exec -it mosquitto mosquitto_passwd -D /mosquitto/config/passwords.txt USERNAME
|
||||
docker compose exec -T mosquitto mosquitto_passwd -D /mosquitto/config/passwords.txt USERNAME
|
||||
|
||||
# Container neu starten
|
||||
docker compose restart mosquitto
|
||||
@@ -257,19 +268,20 @@ Du kannst den Workflow nach dem Import anpassen:
|
||||
### Via Docker
|
||||
|
||||
```bash
|
||||
# Öffentlich (ohne Auth)
|
||||
docker exec mosquitto mosquitto_pub -h localhost -t "public/message" -m "Test Nachricht"
|
||||
# Öffentlich (ohne Auth, read-only → Sub only)
|
||||
docker compose exec -T mosquitto mosquitto_sub -h localhost -t "public/#" -v
|
||||
|
||||
# Mit Auth (Passwort aus .env verwenden)
|
||||
docker exec mosquitto mosquitto_pub -h localhost -t "sensors/temperature" -m "22.5" -u admin -P <ADMIN_PASSWORD>
|
||||
docker exec mosquitto mosquitto_pub -h localhost -t "sensors/humidity" -m "65" -u admin -P <ADMIN_PASSWORD>
|
||||
docker exec mosquitto mosquitto_pub -h localhost -t "system/cpu" -m "45" -u admin -P <ADMIN_PASSWORD>
|
||||
docker compose exec -T mosquitto mosquitto_pub -h localhost -t "sensors/temperature" -m "22.5" -u admin -P <ADMIN_PASSWORD>
|
||||
docker compose exec -T mosquitto mosquitto_pub -h localhost -t "sensors/humidity" -m "65" -u admin -P <ADMIN_PASSWORD>
|
||||
docker compose exec -T mosquitto mosquitto_pub -h localhost -t "system/cpu" -m "45" -u admin -P <ADMIN_PASSWORD>
|
||||
```
|
||||
|
||||
Oder verwende das Test-Script:
|
||||
```bash
|
||||
./test-mqtt.sh
|
||||
```
|
||||
> Das Script lädt Benutzername/Passwort aus `.env` (Variablen `MQTT_ADMIN_USERNAME`/`MQTT_ADMIN_PASSWORD`).
|
||||
|
||||
### Via Python (paho-mqtt)
|
||||
|
||||
@@ -343,23 +355,23 @@ docker compose logs -f mqttui
|
||||
|
||||
```bash
|
||||
# Mosquitto Container
|
||||
docker exec -it mosquitto sh
|
||||
docker compose exec -it mosquitto sh
|
||||
|
||||
# MQTTUI Container
|
||||
docker exec -it mqttui sh
|
||||
docker compose exec -it mqttui sh
|
||||
```
|
||||
|
||||
### Mosquitto Konfiguration testen
|
||||
|
||||
```bash
|
||||
docker exec mosquitto mosquitto -c /mosquitto/config/mosquitto.conf -v
|
||||
docker compose exec -T mosquitto mosquitto -c /mosquitto/config/mosquitto.conf -v
|
||||
```
|
||||
|
||||
### Permissions Fehler
|
||||
|
||||
```bash
|
||||
# Berechtigungen für passwords.txt setzen
|
||||
chmod 644 passwords.txt
|
||||
# Berechtigungen für config/passwords.txt setzen
|
||||
chmod 640 config/passwords.txt
|
||||
```
|
||||
|
||||
### ACL Debug
|
||||
|
||||
Reference in New Issue
Block a user