Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MQTT broker setup #244

Merged
merged 6 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ services:
networks:
- redis

mosquitto_dev:
image: eclipse-mosquitto:2.0
container_name: altzone_mosquitto_dev
ports:
- 1883:1883
networks:
- backend
volumes:
- altzone_mosquitto_dev:/mosquitto/data
- ./mosquitto/config:/mosquitto/config
- ./mosquitto/log:/mosquitto/log

proxy_dev:
build:
dockerfile: dev_nginx.Dockerfile
Expand All @@ -77,4 +89,5 @@ networks:

volumes:
altzone_db_dev:
altzone_redis_dev:
altzone_redis_dev:
altzone_mosquitto_dev:
7 changes: 7 additions & 0 deletions mosquitto/config/aclfile.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Allow the server device to publish to all topics
user publisher
topic write #

# Allow other nodes to subscribe to all topics but not publish
user subscriber
topic read #
26 changes: 26 additions & 0 deletions mosquitto/config/mosquitto.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Server insternal net
listener 1883

#websockets with SSL
listener 9001
protocol websockets

# auth
allow_anonymous false
password_file /mosquitto/config/password_1

# Permissions
acl_file /mosquitto/config/aclfile.conf

# save data to db
persistence true
persistence_location /mosquitto/data/
autosave_interval 900

#logging
#log_dest file /mosquitto/log/mosquitto.log
connection_messages true

#optimization
max_queued_messages 20
memory_limit 512000000
2 changes: 2 additions & 0 deletions mosquitto/config/password_1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
publisher:$7$101$M3QOKHW8D+4Y0ykp$vBiFSzy1aDmBBDWg736lbVOxcGyyAaVxRLquxO/OlIqf2nEOoCEcJgptE/kz/xfHj2yO5QmmBnWmTmAj7BvMfg==
subscriber:$7$101$uiJROPjD9vrWS/DE$pu4oxh4v1oH+VhYs0fM3C9AN37jmi3v7Ypzsja0zAM9fg7ILMdIrzkgoVofGWSu2ZFA/KzWvIc3GG3lA87fRUA==
8 changes: 8 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ http {
try_files $uri $uri/ =404;
}

location /mqtt {
proxy_pass http://altzone_mosquitto_dev:9001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}

# location ^~ /public/metaData {
# try_files $uri $uri/ =404;
# }
Expand Down
21 changes: 19 additions & 2 deletions prod_docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ services:
- REDIS_PASSWORD=mySecretPassword
- REDIS_HOST=redis
- REDIS_PORT=6379

- MOSQUITTO_HOST=mosquitto
- MOSQUITTO_PORT=1883
- MOSQUITTO_SUBSCRIBER_USER=subscriber
- MOSQUITTO_SUBSCRIBER_PASSWORD=subscriberPassword
- MOSQUITTO_PUBLISHER=publisher
- MOSQUITTO_PUBLISHER_PASSWORD=publisherPassword

site:
image: leolab1337/altzone_web_pages:v2
container_name: altzone_site
Expand Down Expand Up @@ -94,6 +100,16 @@ services:
networks:
- redis

mosquitto:
image: eclipse-mosquitto:2.0
container_name: altzone_mosquitto
networks:
- backend
volumes:
- altzone_mosquitto:/mosquitto/data
- ./mosquitto/config:/mosquitto/config
- ./mosquitto/log:/mosquitto/log

owncloud:
image: owncloud/server:10.15
container_name: altzone_owncloud
Expand Down Expand Up @@ -171,4 +187,5 @@ networks:
volumes:
altzone_db:
owncloud_db:
altzone_redis:
altzone_redis:
altzone_mosquitto: