Production-ready Mosquitto 2.1 build featuring WebSockets, Dynamic Security, and Proxy Protocol v2.
1.5K
This directory contains a custom, production-ready build of Mosquitto 2.1.0-test1. It is specifically tailored for deployment on Ubuntu-based environments (Ubuntu 24.04) and includes support for modern MQTT features, enhanced security, and containerized orchestration via Kubernetes.
mosquitto_dynamic_security.so plugin allows for real-time management of users, groups, and ACLs without broker restarts.mosquitto_persist_sqlite.so plugin for robust, high-performance persistent storage, superior to standard file-based persistence in containerized environments.9001, allowing web-based clients to communicate via MQTT.9883.amd64 and arm64 architectures, making it suitable for both cloud servers and edge devices (like Raspberry Pi).| File | Description |
|---|---|
Dockerfile | Multi-stage build file compiling Mosquitto from source on Ubuntu 24.04. It handles complex dependency linking for plugins and mosquitto_ctrl. |
build.sh | A utility script for building multi-architecture Docker images and pushing them to a registry. |
mosquitto_test.conf | The primary configuration file. Includes listeners for MQTT (1883), WebSockets (9001), and the HTTP API (9883). |
mosquitto_test.acl | Initial Access Control List template. |
mosquitto_test.passwd | Default password file (Default: admin:public). |
mosquitto_dynamic-security_test.json | Initial state configuration for the Dynamic Security plugin. |
k3s_mosquitto_deployment.yml | Kubernetes manifest for full-stack deployment including Namespace, Deployment, PVCs, Services, and Traefik IngressRoutes. |
haproxy_test.cfg | Example HAProxy configuration for testing Proxy Protocol v2 locally. |
You can build the image locally using the provided build.sh script:
./build.sh onlylocal
The default configuration mosquitto_test.conf has enable_proxy_protocol 2 enabled. To test this locally, you must run the broker behind a proxy that sends Proxy Protocol v2 headers (like HAProxy).
1. Start Mosquitto (mapping to "twisted" ports as expected by the test HAProxy config):
docker run -d \
--name mosquitto-test \
-p 1884:1883 -p 9002:9001 -p 9884:9883 \
-v $(pwd)/mosquitto_test.conf:/mosquitto/config/mosquitto.conf \
-v $(pwd)/mosquitto_test.passwd:/mosquitto/config/mosquitto.passwd \
-v $(pwd)/mosquitto_dynamic-security_test.json:/mosquitto/data/dynamic-security.json \
-v $(pwd)/mosquitto_test.acl:/mosquitto/config/mosquitto.acl \
--rm xomoxcc/mosquitto:2.1
2. Start HAProxy:
docker run -d \
--name haproxy-test \
--net=host \
-v $(pwd)/haproxy_test.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro \
--rm haproxy:latest
Note: Using --net=host allows HAProxy to easily reach Mosquitto on 127.0.0.1 as configured in haproxy_test.cfg.
3. Test Connection: You can now connect to Mosquitto via HAProxy on the standard ports (1883, 9001, 9883).
The included k3s_mosquitto_deployment.yml is a comprehensive manifest designed for K3s/Kubernetes.
mosquitto - Keeps the deployment isolated.mosquitto-data-pvc, mosquitto-config-pvc, mosquitto-log-pvc) to ensure data survives pod restarts and migrations.kubectl apply -f k3s_mosquitto_deployment.yml
libmosquitto_common.so.1 and libedit.so.0 are correctly handled to ensure mosquitto_ctrl and plugins function out-of-the-box.runmosquitto.sh handles the initial setup of the environment, ensuring that if no configuration or user database exists, a default admin user is created to allow immediate access for testing.Reference: Mosquitto HAProxy Documentationβ
This is a development/experimental project. For production use, review security settings, customize configurations, and test thoroughly in your environment. Provided "as is" without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. Use at your own risk.
Content type
Image
Digest
sha256:991a302f3β¦
Size
76.5 MB
Last updated
4 months ago
docker pull xomoxcc/mosquitto