From 6851b1f1eb7b60a9d65293d26a69e469d4fee295 Mon Sep 17 00:00:00 2001 From: kev Date: Thu, 8 Dec 2022 15:06:17 +0800 Subject: [PATCH] update mosquitto --- mosquitto/README.md | 60 ++++--------------- mosquitto/arm/Dockerfile | 14 ----- mosquitto/arm/data/DST_Root_CA_X3.pem | 20 ------- mosquitto/arm/data/mosquitto.conf | 26 -------- mosquitto/arm/data/privkey.pem | 0 mosquitto/arm/data/pwfile | 0 mosquitto/arm/docker-compose.yml | 10 ---- mosquitto/data/etc/mosquitto.conf | 5 +- .../data/fullchain.pem => data/log/.gitkeep} | 0 mosquitto/docker-compose.yml | 1 + 10 files changed, 17 insertions(+), 119 deletions(-) delete mode 100644 mosquitto/arm/Dockerfile delete mode 100644 mosquitto/arm/data/DST_Root_CA_X3.pem delete mode 100644 mosquitto/arm/data/mosquitto.conf delete mode 100644 mosquitto/arm/data/privkey.pem delete mode 100644 mosquitto/arm/data/pwfile delete mode 100644 mosquitto/arm/docker-compose.yml rename mosquitto/{arm/data/fullchain.pem => data/log/.gitkeep} (100%) diff --git a/mosquitto/README.md b/mosquitto/README.md index 66d5f53..1888904 100644 --- a/mosquitto/README.md +++ b/mosquitto/README.md @@ -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 diff --git a/mosquitto/arm/Dockerfile b/mosquitto/arm/Dockerfile deleted file mode 100644 index 0f020fb..0000000 --- a/mosquitto/arm/Dockerfile +++ /dev/null @@ -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"] diff --git a/mosquitto/arm/data/DST_Root_CA_X3.pem b/mosquitto/arm/data/DST_Root_CA_X3.pem deleted file mode 100644 index b2e43c9..0000000 --- a/mosquitto/arm/data/DST_Root_CA_X3.pem +++ /dev/null @@ -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----- diff --git a/mosquitto/arm/data/mosquitto.conf b/mosquitto/arm/data/mosquitto.conf deleted file mode 100644 index 8312c11..0000000 --- a/mosquitto/arm/data/mosquitto.conf +++ /dev/null @@ -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 diff --git a/mosquitto/arm/data/privkey.pem b/mosquitto/arm/data/privkey.pem deleted file mode 100644 index e69de29..0000000 diff --git a/mosquitto/arm/data/pwfile b/mosquitto/arm/data/pwfile deleted file mode 100644 index e69de29..0000000 diff --git a/mosquitto/arm/docker-compose.yml b/mosquitto/arm/docker-compose.yml deleted file mode 100644 index 1b6a0d4..0000000 --- a/mosquitto/arm/docker-compose.yml +++ /dev/null @@ -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 diff --git a/mosquitto/data/etc/mosquitto.conf b/mosquitto/data/etc/mosquitto.conf index 975793b..02a49d6 100644 --- a/mosquitto/data/etc/mosquitto.conf +++ b/mosquitto/data/etc/mosquitto.conf @@ -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 diff --git a/mosquitto/arm/data/fullchain.pem b/mosquitto/data/log/.gitkeep similarity index 100% rename from mosquitto/arm/data/fullchain.pem rename to mosquitto/data/log/.gitkeep diff --git a/mosquitto/docker-compose.yml b/mosquitto/docker-compose.yml index 3b4e616..072c9df 100644 --- a/mosquitto/docker-compose.yml +++ b/mosquitto/docker-compose.yml @@ -7,4 +7,5 @@ services: volumes: - ./data/etc:/etc/mosquitto - ./data/var:/var/lib/mosquitto + - ./data/log:/var/log/mosquitto restart: unless-stopped