relution/relution-mosquitto

By relution

Updated about 1 year ago

Eclipse Mosquitto MQTT Broker for Relution Docker Image

Image

3.5K

Preconfigured Docker image of the Eclipse Mosquitto MQTT Broker for use with the Relution Server. The image includes the mosquitto-auth-plug compiled with HTTP backend support only. The authenticating server is resolved by hostname as relution so that it can be resolved in a docker-compose script easily.

The ports opened are 8883 supporting MQTT over SSL and 9001 providing MQTT over WSS (secure WebSocket). For this to work the image must be supplied with an SSL server certificate and key which must be mounted as /etc/mosquitto/server.pem and /etc/mosquitto/server.key, respectively.

Docker Compose Snippet

version: "3"
services:
  mosquitto:
    image: relution/relution-mosquitto:latest
    restart: always
    ports:
      - "8883:8883"
      - "9001:9001"
    environment:
      - BLUERANGE_HOSTNAME=${BLUERANGE_HOSTNAME:-localhost}
      - REST_API_ACCESS_TOKEN=${REST_API_ACCESS_TOKEN:-bluerange-change-me}
      - PROMETHEUS_PASSWORD=${PROMETHEUS_PASSWORD:-prometheus-change-me}
    volumes:
      #- './mosquitto.conf:/etc/mosquitto/mosquitto.conf'
      - './server.key:/etc/mosquitto/server.key'
      - './server.pem:/etc/mosquitto/server.pem'
    ulimits:
      nofile: 100000
      nproc: 100000

Binding to localhost

For local Eclipse development you need to alter the auth_opt_http_hostname parameter of the mosquitto.conf file to your local hostname. To do so, mount a local copy of that file. The command line for starting the server mounting a local config-file and server-cert looks like:

> docker -it \
--mount type=bind,source=mosquitto.conf,target=/etc/mosquitto/mosquitto.conf \
--mount type=bind,source=server.key,target=/etc/mosquitto/server.key \
--mount type=bind,source=server.pem,target=/etc/mosquitto/server.pem \
--name relution-mosquitto relution/relution-mosquitto:latest

Relution configuration

Set the following environment variables to configure Relution:

export MQTT_ENABLED=true
export MQTT_SERVER_URIS=ssl://localhost:8883,wss://localhost:9001

The above assumes localhost as name of the host running the image.

Docker Pull Command

docker pull relution/relution-mosquitto