1
0
mirror of https://github.com/daniviga/bite.git synced 2024-12-23 00:31:25 +01:00

Route MQTT via Nginx using strams. Remove Traefik

This commit is contained in:
Daniele Viganò 2023-09-11 17:39:26 +02:00
parent c020d2c9ad
commit c7db2bf1a8
Signed by: dani
GPG Key ID: DB49AFC03C40EE02
7 changed files with 21 additions and 54 deletions

View File

@ -52,7 +52,7 @@ safe configuration (see https://github.com/docker/compose/issues/2999).
```bash
docker-compose -f docker/docker-compose.yml build
docker-compose -f docker/docker-compose.yml up -d [--scale {bite,mqtt-to-db)=N]
docker-compose -f docker/docker-compose.yml up -d [--scale {bite,dispatcher)=N]
```
It exposes:
@ -72,8 +72,10 @@ It exposes:
- `http://localhost:80` (HTTP and MQTT over Websockets)
- `http://localhost:8080` (Django's `runserver`)
- `tcp://localhost:1883` (MQTT)
- `tcp://localhost:9001` (MQTT over Websockets)
- `tcp://localhost:1883` (MQTT via Nginx streams)
- `tcp://localhost:18883` (MQTT via Mosquitto)
- `tcp://localhost:9001` (MQTT over Websockets via Mosquitto)
- `tcp://localhost:29092` (Kafka)
- `udp://localhost:123` (NTP)
- `tcp://localhost:5432` (PostgreSQL/Timescale)
@ -96,13 +98,6 @@ Django runs with `DEBUG = False` and `SKIP_WHITELIST = False`
The project provides multiple modules that can be combined with the fore-mentioned configurations.
### Traefik
To use [Traefik](https://containo.us/traefik/) instead of Nginx use:
```bash
docker-compose -f docker/docker-compose.yml up -f docker/ingress/docker-compose.traefik.yml -d
```
### VerneMQ
A ~8x memory usage can be expected compared to Mosquitto.

View File

@ -26,7 +26,7 @@ services:
broker:
ports:
- "${CUSTOM_DOCKER_IP:-0.0.0.0}:1883:1883"
- "${CUSTOM_DOCKER_IP:-0.0.0.0}:18883:1883"
- "${CUSTOM_DOCKER_IP:-0.0.0.0}:9001:9001"
bite:

View File

@ -59,8 +59,6 @@ services:
- "./mqtt/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf"
networks:
- net
ports:
- "${CUSTOM_DOCKER_IP:-0.0.0.0}:1883:1883"
zookeeper:
image: confluentinc/cp-zookeeper:latest
@ -91,6 +89,7 @@ services:
NGINX_ENTRYPOINT_QUIET_LOGS: 1
ports:
- "${CUSTOM_DOCKER_IP:-0.0.0.0}:80:80"
- "${CUSTOM_DOCKER_IP:-0.0.0.0}:1883:1883"
networks:
- net
volumes:

View File

@ -1,40 +0,0 @@
# -*- coding: utf-8 -*-
# vim: tabstop=2 shiftwidth=2 softtabstop=2
#
# BITE - A Basic/IoT/Example
# Copyright (C) 2020-2021 Daniele Viganò <daniele@vigano.me>
#
# BITE is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# BITE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
version: "3.7"
services:
ingress:
<<: *service_default
image: traefik:v2.2
command: --api.insecure=true --providers.docker
ports:
- "8000:80"
- "8080:8080"
networks:
- net
volumes:
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock
restart: always
init: true
bite:
labels:
- "traefik.http.routers.bite.rule=PathPrefix(`/`)"

View File

@ -55,6 +55,12 @@ http {
}
upstream mqtt {
# We point to the Docker 'service' instead of directly to the container
# Docker does then a DNS round-robin internally
server broker:1883;
}
upstream mqtt-ws {
# We point to the Docker 'service' instead of directly to the container
# Docker does then a DNS round-robin internally
server broker:9001;
@ -85,7 +91,7 @@ http {
}
location /mqtt {
proxy_pass http://mqtt;
proxy_pass http://mqtt-ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
@ -101,3 +107,10 @@ http {
}
}
}
stream {
server {
listen 1883;
proxy_pass mqtt;
}
}

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 121 KiB