Mosquitto MQTT broker #127

Merged
skobkin merged 1 commit from feature_94_mqtt into master 2024-11-07 20:36:54 +00:00
11 changed files with 120 additions and 0 deletions

View file

@ -58,6 +58,7 @@ Not every stack is tested to fully work.
| magneticod | ✅ | `boramalper/magneticod` | DHT indexing daemon. | [Website](https://www.boramalper.org/labs/magnetico/), [Github](https://github.com/boramalper/magnetico) |
| Matrix Telegram Bridge | ✅ | `dock.mau.dev/mautrix/telegram` | Telegram bridge for Matrix server | [Gitlab](https://mau.dev/mautrix/telegram/) |
| Metube | ✅ | `alexta69/metube` | Web GUI for yt-dlp. | [Github](https://github.com/alexta69/metube) |
| Mosquitto | ✅ | `iegomez/mosquitto-go-auth` | Simple and fast MQTT server with Go Auth plugin. | [Plugin Github](https://github.com/iegomez/mosquitto-go-auth), [Mosquitto website](https://mosquitto.org) |
| Murmur (Mumble server) | ✅ | `registry.gitlab.com/skobkin/docker-murmur` | Mumble VoIP server (custom build) | [Website](https://www.mumble.info), [Github](https://github.com/mumble-voip/mumble) |
| Ollama | ✅ | `ollama/ollama` | Toolkit for easily running LLM's locally. | [Website](https://ollama.com), [Github](https://github.com/ollama/ollama) |
| Open Streaming Platform | ✅ | `deamos/openstreamingplatform` | Live streaming platform. | [Website](https://openstreamingplatform.com), [Gitlab](https://gitlab.com/osp-group/flask-nginx-rtmp-manager) |

16
mosquitto/.env.dist Normal file
View file

@ -0,0 +1,16 @@
# Image version for Mosquitto with Go auth plugin
IMAGE_VERSION=latest
# External address binding for Mosquitto ports
BIND_ADDR=127.0.0.1
BIND_PORT_MQTT=1883
BIND_PORT_WS=1884
# Paths for configuration and data persistence
CONFIG_DIR=./config
DATA_DIR=./data
LOG_DIR=./logs
# Logging options
LOG_MAX_SIZE=5m
LOG_MAX_FILE=5

26
mosquitto/README.md Normal file
View file

@ -0,0 +1,26 @@
# Usage
## Configuration
```shell
cp config/files/acls.dist config/files/acls
cp config/files/passwords.dist config/files/passwords
cp config/files/passwords.dist config/files/passwords
cp config/mosquitto.conf.dist config/mosquitto.conf
```
Edit configuration to suit your needs.
## Passwords
To generate password hashes, you can use `pw` tool located at the `/mosquitto/pw` inside the container.
```shell
docker compose exec mosquitto sh
/mosquitto/pw --help
/mosquitto/pw -p MyPasswordString
```
## ACL's
Refer to the [documentation](https://github.com/iegomez/mosquitto-go-auth?tab=readme-ov-file#acl-file).

3
mosquitto/config/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
mosquitto.conf
files/passwords
files/acls

View file

@ -0,0 +1,19 @@
# Path to the Go auth plugin shared object
auth_plugin /mosquitto/go-auth.so
# Configure the authentication backends (adjust as needed)
auth_opt_backends files
# Specify the paths for passwords and ACLs
# https://github.com/iegomez/mosquitto-go-auth?tab=readme-ov-file#files
# Hashes may be generated using the `/mosquitto/pw` utility
auth_opt_files_password_path /etc/mosquitto/files/passwords
auth_opt_files_acl_path /etc/mosquitto/files/acls
# Plugin-specific options (examples)
# https://github.com/iegomez/mosquitto-go-auth?tab=readme-ov-file#configuration
# auth_opt_postgres_host=db
# auth_opt_postgres_port=5432
# auth_opt_postgres_user=user
# auth_opt_postgres_password=password
# auth_opt_postgres_dbname=mqtt

View file

@ -0,0 +1,12 @@
user test1
topic write test/topic/1
topic read test/topic/2
user test2
topic read test/topic/+
user test3
topic read test/#
pattern read test/%u
pattern read test/%c

View file

@ -0,0 +1,2 @@
test1:PBKDF2$sha512$100000$2WQHK5rjNN+oOT+TZAsWAw==$TDf4Y6J+9BdnjucFQ0ZUWlTwzncTjOOeE00W4Qm8lfPQyPCZACCjgfdK353jdGFwJjAf6vPAYaba9+z4GWK7Gg==
test2:PBKDF2$sha512$100000$o513B9FfaKTL6xalU+UUwA==$mAUtjVg1aHkDpudOnLKUQs8ddGtKKyu+xi07tftd5umPKQKnJeXf1X7RpoL/Gj/ZRdpuBu5GWZ+NZ2rYyAsi1g==

View file

@ -0,0 +1,18 @@
# Mosquitto configuration
persistence true
persistence_location /data/
log_dest file /logs/mosquitto.log
# Default listener for unencrypted connections
listener 1883
allow_anonymous false
# Optional TLS listener
listener 1884
# Uncomment and configure the following for TLS
# cafile /etc/mosquitto/ca_certificates/ca.crt
# certfile /etc/mosquitto/certs/server.crt
# keyfile /etc/mosquitto/certs/server.key
# Include directory for additional configuration files
include_dir /etc/mosquitto/conf.d

2
mosquitto/data/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/*
!/.gitignore

View file

@ -0,0 +1,19 @@
services:
mosquitto:
image: "iegomez/mosquitto-go-auth:${IMAGE_VERSION:-latest}"
container_name: mosquitto
hostname: mosquitto
volumes:
- "${CONFIG_DIR:-./config}:/etc/mosquitto"
- "${DATA_DIR:-./data}:/data"
- "${LOG_DIR:-./logs}:/logs"
ports:
- "${BIND_ADDR:-127.0.0.1}:${BIND_PORT_MQTT:-1883}:1883"
- "${BIND_ADDR:-127.0.0.1}:${BIND_PORT_WS:-1884}:1884"
env_file: .env
restart: unless-stopped
logging:
driver: "json-file"
options:
max-size: "${LOG_MAX_SIZE:-5m}"
max-file: "${LOG_MAX_FILE:-5}"

2
mosquitto/logs/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/*
!/.gitignore