mirror of
https://github.com/unifi-utilities/unifios-utilities.git
synced 2024-08-30 18:32:21 +00:00
[mosquitto] Update guide with more docs, removed outdated cni configs & cleaned mosquitto.conf (#413)
* Remove the 'mqtt-' prefix from mosquittos directory * Fix invalid cni conflist filename for mosquitto * Minor guide intro rephrasing * Commit 45-mosquitto.sh with execute permissions added * Cleanup config from options which are already provided by default * Minor mosquitto guide refactor & cleanup * Update reference to mosquitto guide * Fix typo
This commit is contained in:
parent
af47c80012
commit
7fcb9c77b1
@ -102,7 +102,7 @@ Update your cloudflare domains from your UDM with podman.
|
||||
| Name | URL | Description |
|
||||
|------ |----- |------------- |
|
||||
|multicast-relay |<https://hub.docker.com/r/scyto/multicast-relay> | This is a docker container that implements <https://github.com/alsmith/multicast-relay> to provide mDNS and SSDP on a unifi dream machine. It will likely work on any multi homed host. |
|
||||
| mqtt-mosquitto | <https://hub.docker.com/_/eclipse-mosquitto> | Eclipse Mosquitto is an open source message broker which implements MQTT version 5, 3.1.1 and 3.1. |
|
||||
| [mosquitto](./mosquitto/) | <https://hub.docker.com/_/eclipse-mosquitto> | Eclipse Mosquitto is an open source **MQTT message broker** |
|
||||
| ntopng | <https://github.com/tusc/ntopng-udm> | Much better network stats for your UDM/P! Install this docker container and create an on_boot script to make sure it's always running. |
|
||||
| LetsEncrypt | <https://github.com/kchristensen/udm-le> |Provision and renew LetsEncrypt SSL certs from your UDM/P. |
|
||||
| ubios-cert | <https://github.com/alxwolf/ubios-cert> | Provision and renew SSL/TLS certificates from LetsEncrypt, ZeroSSL, BuyPass, Google and any other RFC8555-compliant CA. Runs `acme.sh` on your UDM, UDM Pro, UDM SE or UDR. No podman required, supports both V1.x and V2.x firmwares. Secure your HTTPS connections to device, WiFiman and Guest Portal. |
|
||||
|
@ -5,35 +5,42 @@
|
||||
## Prerequisities
|
||||
|
||||
- Working **`on_boot.d`** setup (check [unifi-utilities/unifios-utilities#on-boot-script](https://github.com/unifi-utilities/unifios-utilities/tree/main/on-boot-script) for instructions)
|
||||
- A VLAN network (you can use one you're already using)
|
||||
- A VLAN network (you can use one you are already using)
|
||||
|
||||
#### Optional:
|
||||
**Recommended**
|
||||
|
||||
- [container-common](../container-common/README.md) to prevent growing disk usage from accumulating logs
|
||||
- Port forwarding, ie. WAN -> 10.0.20.4 (TCP/1883) if needed
|
||||
- Use [container-common](../container-common/README.md) to prevent growing disk usage from accumulating logs
|
||||
|
||||
> **Note:** Throughout this guide I'm using `VLAN 20` with gateway `10.0.20.1/24`, Mosquitto's IP will be `10.0.20.4`.
|
||||
> Adjust according to your setup.
|
||||
**Optional**
|
||||
|
||||
- Port forwarding, ie. WAN -> [MOSQUITTO_IP] (TCP/1883) if needed
|
||||
|
||||
**Note**
|
||||
Throughout this guide I'm using `VLAN 20` with gateway `10.0.20.1/24` as an example; Mosquitto's IP will be `10.0.20.4`.
|
||||
_Adjust according to your setup._
|
||||
|
||||
## Setup
|
||||
|
||||
1. First, lets create the folder structure we'll be working with.
|
||||
|
||||
`$ mkdir -p /mnt/data/mosquitto/data /mnt/data/mosquitto/config`
|
||||
`$ mkdir -p /mnt/data/mosquitto/config /mnt/data/mosquitto/data`
|
||||
|
||||
2. Customize [`on_boot.d/45-mosquitto.sh`](on_boot.d/45-mosquitto.sh) to your needs and copy to `/mnt/data/on_boot.d/`.
|
||||
This is where Mosquitto's configuration file and data ("persistence database"; if enabled) will live.
|
||||
If you're unsure on how to configure mosquitto, use the provided barebone config [`config/mosquitto.conf`](config/mosquitto.conf) to get it initially running.
|
||||
|
||||
2. **Optional:** Customize [`on_boot.d/45-mosquitto.sh`](on_boot.d/45-mosquitto.sh) to your setup and copy to `/mnt/data/on_boot.d/`.
|
||||
Most likely you'll need to mark the script as executable, this will do the trick:
|
||||
|
||||
`$ chmod a+x /mnt/data/on_boot.d/45-mosquitto.sh`
|
||||
|
||||
3. Also edit [`cni/45-mosquitto.conflist`](cni/45-mosquitto.conflist) according your configuration and copy to `/mnt/data/podman/cni/`.
|
||||
3. Then take a loot at [`cni/45-mosquitto.conflist`](cni/45-mosquitto.conflist) and make sure it matches your previously defined configuration; then place it in `/mnt/data/podman/cni/`
|
||||
|
||||
4. Run boot script (to create update network and create CNI configuration for container)
|
||||
4. Run boot script (to create the mosquitto network set it's ip routes)
|
||||
|
||||
`$ sh /mnt/data/on_boot.d/45-mosquitto.sh`
|
||||
|
||||
It fail when trying to run the container, but thats okay, its just for setting op needed configuration before initial image run.
|
||||
The script will also create a [bare-metal configuration](config/mosquitto.conf) for Mosquitto in `/mnt/data/mosquitto/config/`.
|
||||
The script will also create a [minimal configuration](config/mosquitto.conf) for Mosquitto in `/mnt/data/mosquitto/config/`, _**only if it doesn't already exist**_.
|
||||
|
||||
> **Note:** You can use this config to get everything started, but I highly recommend securing your instance with authentication (links to the offical documentation & other resources are at the bottom)
|
||||
|
||||
@ -59,22 +66,19 @@
|
||||
|
||||
## Commands
|
||||
|
||||
#### Updates
|
||||
**Updates**
|
||||
To update container image to its latest version, first delete the current container (`$ podman stop mosquitto && podman rm mosquitto`) and follow through setup steps 5. & 6.
|
||||
|
||||
To update container image, simple do `$ podman stop mosquitto && podman rm mosquitto` and run boot script again.
|
||||
**Logs**
|
||||
If you want to know what mosquitto is doing, run `$ podman logs -f mosquitto` to follow the logs.
|
||||
|
||||
#### Logs
|
||||
|
||||
If you want to know what Mosquitto is doing, run `$ podman logs -f mosquitto` to follow the logs.
|
||||
|
||||
## References
|
||||
## Relevant Links
|
||||
|
||||
- [Eclipse Mosquitto Homepage](https://mosquitto.org)
|
||||
- [mosquitto.conf man page](https://mosquitto.org/man/mosquitto-conf-5.html)
|
||||
- [Setting up Authentication in Mosquitto MQTT Broker](https://medium.com/@eranda/setting-up-authentication-on-mosquitto-mqtt-broker-de5df2e29afc)
|
||||
- [eclipse-mosquitto on Docker-Hub](https://hub.docker.com/_/eclipse-mosquitto/)
|
||||
|
||||
## Credits
|
||||
|
||||
Huge thanks to @boostchicken and his incredible work on [unifios-utilities](https://github.com/unifi-utilities/unifios-utilities)!
|
||||
|
||||
Guide based upon the incredible contributors of [boostchicken/unifios-utilities](https://github.com/unifi-utilities/unifios-utilities)!
|
||||
Huge thanks to @boostchicken for his incredible work on [unifios-utilities](https://github.com/unifi-utilities/unifios-utilities) and all contributors of this repo!
|
@ -1,14 +1,11 @@
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
|
||||
connection_messages true
|
||||
|
||||
allow_anonymous true
|
||||
allow_zero_length_clientid true
|
||||
|
||||
persistence true
|
||||
persistence_file mosquitto.db
|
||||
persistence_location /mosquitto/data/
|
||||
persistent_client_expiration 7d
|
||||
|
||||
log_dest stdout
|
||||
log_type debug
|
||||
log_timestamp true
|
||||
log_timestamp true
|
12
mqtt-mosquitto/on_boot.d/45-mosquitto.sh → mosquitto/on_boot.d/45-mosquitto.sh
Normal file → Executable file
12
mqtt-mosquitto/on_boot.d/45-mosquitto.sh → mosquitto/on_boot.d/45-mosquitto.sh
Normal file → Executable file
@ -40,24 +40,18 @@ ip route add ${IPV4_IP_CONTAINER}/32 dev br${VLAN_ID}.mac
|
||||
# create basic config if not exist
|
||||
if ! test -f /mnt/data/mosquitto/config/mosquitto.conf; then
|
||||
mkdir -p /mnt/data/mosquitto/data /mnt/data/mosquitto/config
|
||||
cat > /mnt/data/mosquitto/mosquitto.conf<< EOF
|
||||
cat > /mnt/data/mosquitto/config/mosquitto.conf<< EOF
|
||||
listener 1883
|
||||
allow_anonymous true
|
||||
|
||||
allow_zero_length_clientid true
|
||||
connection_messages true
|
||||
|
||||
persistence false
|
||||
persistence_file mosquitto.db
|
||||
persistence true
|
||||
persistence_location /mosquitto/data/
|
||||
persistent_client_expiration 7d
|
||||
|
||||
log_dest stdout
|
||||
log_type debug
|
||||
log_timestamp true
|
||||
|
||||
connection_messages true
|
||||
|
||||
allow_anonymous true
|
||||
EOF
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user