diff --git a/docker-compose.yml b/docker-compose.yml index 41b0b91d..4ffb5d78 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 @@ -77,4 +89,5 @@ networks: volumes: altzone_db_dev: - altzone_redis_dev: \ No newline at end of file + altzone_redis_dev: + altzone_mosquitto_dev: \ No newline at end of file diff --git a/mosquitto/config/aclfile.conf b/mosquitto/config/aclfile.conf new file mode 100644 index 00000000..be73ae31 --- /dev/null +++ b/mosquitto/config/aclfile.conf @@ -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 # \ No newline at end of file diff --git a/mosquitto/config/mosquitto.conf b/mosquitto/config/mosquitto.conf new file mode 100644 index 00000000..d9878370 --- /dev/null +++ b/mosquitto/config/mosquitto.conf @@ -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 \ No newline at end of file diff --git a/mosquitto/config/password_1 b/mosquitto/config/password_1 new file mode 100644 index 00000000..b529f9cc --- /dev/null +++ b/mosquitto/config/password_1 @@ -0,0 +1,2 @@ +publisher:$7$101$M3QOKHW8D+4Y0ykp$vBiFSzy1aDmBBDWg736lbVOxcGyyAaVxRLquxO/OlIqf2nEOoCEcJgptE/kz/xfHj2yO5QmmBnWmTmAj7BvMfg== +subscriber:$7$101$uiJROPjD9vrWS/DE$pu4oxh4v1oH+VhYs0fM3C9AN37jmi3v7Ypzsja0zAM9fg7ILMdIrzkgoVofGWSu2ZFA/KzWvIc3GG3lA87fRUA== diff --git a/nginx.conf b/nginx.conf index 19b4b884..ed614628 100644 --- a/nginx.conf +++ b/nginx.conf @@ -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; # } diff --git a/prod_docker-compose.yml b/prod_docker-compose.yml index 38353556..774eeab4 100644 --- a/prod_docker-compose.yml +++ b/prod_docker-compose.yml @@ -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 @@ -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 @@ -171,4 +187,5 @@ networks: volumes: altzone_db: owncloud_db: - altzone_redis: \ No newline at end of file + altzone_redis: + altzone_mosquitto: \ No newline at end of file