Etap 3: broker EMQX z TLS i ACL, symulator czujnika ciśnienia, instrukcja
- docker-compose: EMQX 5.8.6 (1883/8883/18083), symulator (FastAPI, MQTT 5), sniffer tcpdump - emqx.conf, acl.conf: uwierzytelnianie, autoryzacja (default deny), TLS - hasła wyłącznie w pliku .env (poza repozytorium), konta tworzone przy starcie brokera - skrypty: generowanie certyfikatów, podgląd w Wiresharku, klient SCADA - INSTRUKCJA.md: wykonanie zadań i zbieranie dowodów do sprawozdania - screeny/: zrzuty ekranu do sprawozdania Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
76c79e18e8
commit
9bcca5d9e3
35 files changed
+2162
No files matched your search
@@ -0,0 +1,120 @@
|
||||
# Etap 3 - bezpieczeństwo komunikacji MQTT
|
||||
# emqx - broker MQTT (1883 jawnie, 8883 TLS, 18083 panel WWW)
|
||||
# simulator - symulator czujnika ciśnienia z panelem WWW (http://localhost:8000)
|
||||
# sniffer - tcpdump w przestrzeni sieciowej brokera -> podgląd ruchu w Wiresharku
|
||||
# mqtt-cli - klienci mosquitto_pub/sub do testów (np. jako scada_panel), profil "tools"
|
||||
#
|
||||
# Przed pierwszym uruchomieniem:
|
||||
# 1. cp .env.example .env i ustaw w nim hasła
|
||||
# 2. ./scripts/generate-certs.sh
|
||||
|
||||
name: iot-etap3
|
||||
|
||||
services:
|
||||
emqx:
|
||||
image: emqx/emqx:5.8.6
|
||||
container_name: emqx-broker
|
||||
hostname: emqx
|
||||
# tworzy konta urządzeń z haseł w .env, następnie uruchamia EMQX
|
||||
entrypoint: ["/bin/sh", "/opt/emqx/etc/init-users.sh"]
|
||||
command: ["/opt/emqx/bin/emqx", "foreground"]
|
||||
environment:
|
||||
EMQX_NODE__NAME: [email protected] # pojedynczy węzeł - stała nazwa
|
||||
EMQX_NODE__COOKIE: ${EMQX_NODE_COOKIE:?Ustaw EMQX_NODE_COOKIE w pliku .env}
|
||||
EMQX_DASHBOARD__DEFAULT_PASSWORD: ${EMQX_DASHBOARD_PASSWORD:?Ustaw EMQX_DASHBOARD_PASSWORD w pliku .env}
|
||||
SENSOR_PASSWORD: ${SENSOR_PASSWORD:?Ustaw SENSOR_PASSWORD w pliku .env}
|
||||
SCADA_PASSWORD: ${SCADA_PASSWORD:?Ustaw SCADA_PASSWORD w pliku .env}
|
||||
ports:
|
||||
- "1883:1883" # MQTT bez szyfrowania
|
||||
- "8883:8883" # MQTT przez TLS
|
||||
- "18083:18083" # EMQX Dashboard (admin / EMQX_DASHBOARD_PASSWORD)
|
||||
volumes:
|
||||
- ./emqx/emqx.conf:/opt/emqx/etc/emqx.conf:ro
|
||||
- ./emqx/acl.conf:/opt/emqx/etc/acl.conf:ro
|
||||
- ./emqx/init-users.sh:/opt/emqx/etc/init-users.sh:ro
|
||||
- type: bind
|
||||
source: ./certs/ca.crt
|
||||
target: /opt/emqx/etc/certs/iot/ca.crt
|
||||
read_only: true
|
||||
bind: {create_host_path: false} # brak pliku = błąd (najpierw scripts/generate-certs.sh)
|
||||
- type: bind
|
||||
source: ./certs/server.crt
|
||||
target: /opt/emqx/etc/certs/iot/server.crt
|
||||
read_only: true
|
||||
bind: {create_host_path: false} # brak pliku = błąd (najpierw scripts/generate-certs.sh)
|
||||
- type: bind
|
||||
source: ./certs/server.key
|
||||
target: /opt/emqx/etc/certs/iot/server.key
|
||||
read_only: true
|
||||
bind: {create_host_path: false} # brak pliku = błąd (najpierw scripts/generate-certs.sh)
|
||||
- emqx_data:/opt/emqx/data
|
||||
healthcheck:
|
||||
test: ["CMD", "/opt/emqx/bin/emqx", "ctl", "status"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 20
|
||||
start_period: 10s
|
||||
restart: unless-stopped
|
||||
networks: [iot-net]
|
||||
|
||||
simulator:
|
||||
build: ./simulator
|
||||
container_name: pressure-simulator
|
||||
environment:
|
||||
MQTT_HOST: emqx
|
||||
MQTT_TLS: "false" # domyślny tryb w panelu (można zmienić w UI)
|
||||
MQTT_TLS_VERSION: "1.2"
|
||||
MQTT_CA_FILE: /certs/ca.crt
|
||||
MQTT_USERNAME: czujnik_cisnienia
|
||||
# hasła z .env - tylko do wstępnego wypełnienia formularza w panelu
|
||||
MQTT_PASSWORD: ${SENSOR_PASSWORD:?Ustaw SENSOR_PASSWORD w pliku .env}
|
||||
SCADA_PASSWORD: ${SCADA_PASSWORD:?Ustaw SCADA_PASSWORD w pliku .env}
|
||||
SENSOR_ID: PT-101
|
||||
PUBLISH_INTERVAL: "2"
|
||||
# Opcjonalnie: zapis kluczy sesji TLS do odszyfrowania ruchu w Wiresharku
|
||||
TLS_KEYLOG_FILE: ${TLS_KEYLOG_FILE:-}
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- type: bind
|
||||
source: ./certs/ca.crt
|
||||
target: /certs/ca.crt
|
||||
read_only: true
|
||||
bind: {create_host_path: false} # brak pliku = błąd (najpierw scripts/generate-certs.sh)
|
||||
- ./captures:/captures
|
||||
depends_on:
|
||||
emqx:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
networks: [iot-net]
|
||||
|
||||
sniffer:
|
||||
build: ./sniffer
|
||||
container_name: mqtt-sniffer
|
||||
network_mode: "service:emqx"
|
||||
cap_add: [NET_ADMIN, NET_RAW]
|
||||
volumes:
|
||||
- ./captures:/captures
|
||||
depends_on:
|
||||
emqx:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
|
||||
mqtt-cli:
|
||||
image: eclipse-mosquitto:2
|
||||
profiles: ["tools"]
|
||||
entrypoint: []
|
||||
volumes:
|
||||
- ./certs/ca.crt:/certs/ca.crt:ro
|
||||
networks: [iot-net]
|
||||
|
||||
networks:
|
||||
iot-net:
|
||||
name: iot-net
|
||||
driver: bridge
|
||||
driver_opts:
|
||||
# stała nazwa interfejsu mostka - przydatna przy natywnym Dockerze (nie Desktop)
|
||||
com.docker.network.bridge.name: br-iot
|
||||
|
||||
volumes:
|
||||
emqx_data:
|
||||
Reference in new issue
Block a user