mirror of
https://github.com/daniviga/bite.git
synced 2024-11-22 21:16:12 +01:00
Route MQTT via Nginx using strams. Remove Traefik
This commit is contained in:
parent
c020d2c9ad
commit
c7db2bf1a8
15
README.md
15
README.md
|
@ -52,7 +52,7 @@ safe configuration (see https://github.com/docker/compose/issues/2999).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker-compose -f docker/docker-compose.yml build
|
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:
|
It exposes:
|
||||||
|
|
||||||
|
@ -72,8 +72,10 @@ It exposes:
|
||||||
|
|
||||||
- `http://localhost:80` (HTTP and MQTT over Websockets)
|
- `http://localhost:80` (HTTP and MQTT over Websockets)
|
||||||
- `http://localhost:8080` (Django's `runserver`)
|
- `http://localhost:8080` (Django's `runserver`)
|
||||||
- `tcp://localhost:1883` (MQTT)
|
- `tcp://localhost:1883` (MQTT via Nginx streams)
|
||||||
- `tcp://localhost:9001` (MQTT over Websockets)
|
- `tcp://localhost:18883` (MQTT via Mosquitto)
|
||||||
|
- `tcp://localhost:9001` (MQTT over Websockets via Mosquitto)
|
||||||
|
- `tcp://localhost:29092` (Kafka)
|
||||||
- `udp://localhost:123` (NTP)
|
- `udp://localhost:123` (NTP)
|
||||||
- `tcp://localhost:5432` (PostgreSQL/Timescale)
|
- `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.
|
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
|
### VerneMQ
|
||||||
|
|
||||||
A ~8x memory usage can be expected compared to Mosquitto.
|
A ~8x memory usage can be expected compared to Mosquitto.
|
||||||
|
|
|
@ -26,7 +26,7 @@ services:
|
||||||
|
|
||||||
broker:
|
broker:
|
||||||
ports:
|
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"
|
- "${CUSTOM_DOCKER_IP:-0.0.0.0}:9001:9001"
|
||||||
|
|
||||||
bite:
|
bite:
|
||||||
|
|
|
@ -59,8 +59,6 @@ services:
|
||||||
- "./mqtt/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf"
|
- "./mqtt/mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf"
|
||||||
networks:
|
networks:
|
||||||
- net
|
- net
|
||||||
ports:
|
|
||||||
- "${CUSTOM_DOCKER_IP:-0.0.0.0}:1883:1883"
|
|
||||||
|
|
||||||
zookeeper:
|
zookeeper:
|
||||||
image: confluentinc/cp-zookeeper:latest
|
image: confluentinc/cp-zookeeper:latest
|
||||||
|
@ -91,6 +89,7 @@ services:
|
||||||
NGINX_ENTRYPOINT_QUIET_LOGS: 1
|
NGINX_ENTRYPOINT_QUIET_LOGS: 1
|
||||||
ports:
|
ports:
|
||||||
- "${CUSTOM_DOCKER_IP:-0.0.0.0}:80:80"
|
- "${CUSTOM_DOCKER_IP:-0.0.0.0}:80:80"
|
||||||
|
- "${CUSTOM_DOCKER_IP:-0.0.0.0}:1883:1883"
|
||||||
networks:
|
networks:
|
||||||
- net
|
- net
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
@ -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(`/`)"
|
|
|
@ -55,6 +55,12 @@ http {
|
||||||
}
|
}
|
||||||
|
|
||||||
upstream mqtt {
|
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
|
# We point to the Docker 'service' instead of directly to the container
|
||||||
# Docker does then a DNS round-robin internally
|
# Docker does then a DNS round-robin internally
|
||||||
server broker:9001;
|
server broker:9001;
|
||||||
|
@ -85,7 +91,7 @@ http {
|
||||||
}
|
}
|
||||||
|
|
||||||
location /mqtt {
|
location /mqtt {
|
||||||
proxy_pass http://mqtt;
|
proxy_pass http://mqtt-ws;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection $connection_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 |
Loading…
Reference in New Issue
Block a user