1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-12-21 01:27:01 +02:00

update mosquitto

This commit is contained in:
kev 2022-12-08 15:06:17 +08:00
parent e7190c7814
commit 6851b1f1eb
10 changed files with 17 additions and 119 deletions

View File

@ -6,42 +6,9 @@ mosquitto
[Mosquitto][1] is an open source (BSD licensed) message broker that implements
the MQTT protocol versions 3.1 and 3.1.1.
## docker-compose.yml
## server
```yaml
version: "3.8"
services:
mosquitto:
image: vimagick/mosquitto
ports:
- "1883:1883"
volumes:
- ./data/etc:/etc/mosquitto
- ./data/var:/var/lib/mosquitto
restart: unless-stopped
```
## mosquitto.conf
```ini
listener 1883
log_dest stdout
allow_anonymous false
password_file /etc/mosquitto/pwfile
persistence true
persistence_location /var/lib/mosquitto
persistence_file mosquitto.db
#plugin /usr/lib/mosquitto_dynamic_security.so
#plugin_opt_config_file /etc/mosquitto/dynamic-security.json
###### ENABLE TLS ######
listener 8883
protocol mqtt
capath /etc/ssl/certs
certfile /var/lib/mosquitto/fullchain.pem
keyfile /var/lib/mosquitto/privkey.pem
require_certificate false
```
Sample config file: [mosquitto.conf](https://github.com/vimagick/dockerfiles/blob/master/mosquitto/data/etc/mosquitto.conf)
- `pwfile` is managed by [mosquitto_passwd][3].
- Two methods to support TLS:
@ -50,10 +17,8 @@ require_certificate false
> It is important to use different certificate subject parameters for your self-signed CA, server and clients.
## server
```bash
$ mkdir -p data/{etc,var}
$ mkdir -p data/{etc,var,log}
$ chmod -R 777 data
$ touch data/etc/mosquitto.conf data/etc/pwfile
$ vi data/etc/mosquitto.conf
@ -65,16 +30,15 @@ $ docker-compose exec mosquitto sh
username:$6$IuF7JUzS1k/QoF3y$YpiClom7/==
>>> exit
$ docker-compose restart
$ docker-compose logs -f
Attaching to mosquitto_mosquitto_1
mosquitto_1 | 1478107412: mosquitto version 1.4.8 (build date 2016-05-16 14:17:19+0000) starting
mosquitto_1 | 1478107412: Config loaded from /etc/mosquitto/mosquitto.conf.
mosquitto_1 | 1478107412: Opening ipv4 listen socket on port 8883.
mosquitto_1 | 1478107412: Opening ipv6 listen socket on port 8883.
mosquitto_1 | 1478107437: New connection from 192.168.31.102 on port 8883.
mosquitto_1 | 1478107437: New client connected from 192.168.31.102 as mosqsub/38158-Kevins-Ma (c1, k60).
mosquitto_1 | 1478107585: New client connected from 192.168.31.102 as mosqpub/38324-Kevins-Ma (c1, k60).
mosquitto_1 | 1478107585: Client mosqpub/38324-Kevins-Ma disconnected.
$ tails -f data/log/mosquitto.log
2022-12-08T06:59:00: mosquitto version 1.4.8 (build date 2016-05-16 14:17:19+0000) starting
2022-12-08T06:59:01: Config loaded from /etc/mosquitto/mosquitto.conf.
2022-12-08T06:59:02: Opening ipv4 listen socket on port 8883.
2022-12-08T06:59:03: Opening ipv6 listen socket on port 8883.
2022-12-08T06:59:04: New connection from 192.168.31.102 on port 8883.
2022-12-08T06:59:05: New client connected from 192.168.31.102 as mosqsub/38158-Kevins-Ma (c1, k60).
2022-12-08T06:59:06: New client connected from 192.168.31.102 as mosqpub/38324-Kevins-Ma (c1, k60).
2022-12-08T06:59:07: Client mosqpub/38324-Kevins-Ma disconnected.
```
## client

View File

@ -1,14 +0,0 @@
#
# Dockerfile for mosquitto-arm
#
FROM alpine:3
MAINTAINER EasyPi Software Foundation
RUN apk add --no-cache ca-certificates mosquitto
VOLUME /etc/mosquitto
EXPOSE 1883 8883
ENTRYPOINT ["mosquitto"]
CMD ["-c", "/etc/mosquitto/mosquitto.conf"]

View File

@ -1,20 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow
PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD
Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O
rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq
OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b
xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw
7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD
aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG
SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69
ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr
AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz
R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5
JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo
Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ
-----END CERTIFICATE-----

View File

@ -1,26 +0,0 @@
#
# Docs: https://mosquitto.org/man/mosquitto-conf-5.html
#
port 1883
log_dest stdout
allow_anonymous false
password_file /etc/mosquitto/pwfile
persistence true
persistence_location /var/lib/mosquitto/
###### ENABLE WS ######
#listener 8080
#protocol websockets
#capath /etc/ssl/certs
#certfile /var/lib/mosquitto/fullchain.pem
#keyfile /var/lib/mosquitto/privkey.pem
#require_certificate false
###### ENABLE TLS ######
#listener 8883
#protocol mqtt
#capath /etc/ssl/certs
#certfile /var/lib/mosquitto/fullchain.pem
#keyfile /var/lib/mosquitto/privkey.pem
#require_certificate false

View File

@ -1,10 +0,0 @@
version: "3.8"
services:
mosquitto:
image: easypi/mosquitto-arm64
ports:
- "1883:1883"
volumes:
- ./data/etc:/etc/mosquitto
- ./data/var:/var/lib/mosquitto
restart: unless-stopped

View File

@ -3,7 +3,10 @@
#
listener 1883
log_dest stdout
#log_dest stdout
log_dest file /var/log/mosquitto/mosquitto.log
log_timestamp true
log_timestamp_format %Y-%m-%dT%H:%M:%S
allow_anonymous false
password_file /etc/mosquitto/pwfile
persistence true

View File

@ -7,4 +7,5 @@ services:
volumes:
- ./data/etc:/etc/mosquitto
- ./data/var:/var/lib/mosquitto
- ./data/log:/var/log/mosquitto
restart: unless-stopped