From b0a765aff7a5f2c87636c0a0a50946fa863c254f Mon Sep 17 00:00:00 2001 From: Christian Risi <75698846+CnF-Gris@users.noreply.github.com> Date: Tue, 19 Nov 2024 20:53:55 +0100 Subject: [PATCH] Initial Commit, Everything is working fine --- .devcontainer/IoT-Simulator/devcontainer.json | 24 ++++++++++ .../Leader-Service/devcontainer.json | 24 ++++++++++ .../Nginx-Mediator/devcontainer.json | 24 ++++++++++ .gitmodules | 3 ++ Leader-Service | 1 + docker-compose.yaml | 45 +++++++++++++++++++ nginx/proxy.conf | 33 ++++++++++++++ 7 files changed, 154 insertions(+) create mode 100644 .devcontainer/IoT-Simulator/devcontainer.json create mode 100644 .devcontainer/Leader-Service/devcontainer.json create mode 100644 .devcontainer/Nginx-Mediator/devcontainer.json create mode 160000 Leader-Service create mode 100644 docker-compose.yaml create mode 100644 nginx/proxy.conf diff --git a/.devcontainer/IoT-Simulator/devcontainer.json b/.devcontainer/IoT-Simulator/devcontainer.json new file mode 100644 index 0000000..31366ce --- /dev/null +++ b/.devcontainer/IoT-Simulator/devcontainer.json @@ -0,0 +1,24 @@ +{ + // Displayed name + "name": "IoT-Simulator", + + // Service name from compose file + "service": "iot-simulator", + + // Compose-File + "dockerComposeFile": ["../../docker-compose.yaml"], + + // The WorkspaceFolder inside container + "workspaceFolder": "/workspace/IoT-Simulator", + + // Env in container + "containerEnv": { + + } + + + + + + +} \ No newline at end of file diff --git a/.devcontainer/Leader-Service/devcontainer.json b/.devcontainer/Leader-Service/devcontainer.json new file mode 100644 index 0000000..c26151b --- /dev/null +++ b/.devcontainer/Leader-Service/devcontainer.json @@ -0,0 +1,24 @@ +{ + // Displayed name + "name": "Leader-Service", + + // Service name from compose file + "service": "leader-service", + + // Compose-File + "dockerComposeFile": ["../../docker-compose.yaml"], + + // The WorkspaceFolder inside container + "workspaceFolder": "/workspace/Leader-Service", + + // Env in container + "containerEnv": { + + } + + + + + + +} \ No newline at end of file diff --git a/.devcontainer/Nginx-Mediator/devcontainer.json b/.devcontainer/Nginx-Mediator/devcontainer.json new file mode 100644 index 0000000..d84c48d --- /dev/null +++ b/.devcontainer/Nginx-Mediator/devcontainer.json @@ -0,0 +1,24 @@ +{ + // Displayed name + "name": "nginx-mediator", + + // Service name from compose file + "service": "nginx-mediator", + + // Compose-File + "dockerComposeFile": ["../../docker-compose.yaml"], + + // The WorkspaceFolder inside container + "workspaceFolder": "/workspace/nginx", + + // Env in container + "containerEnv": { + + } + + + + + + +} \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 13858c0..9b3dc14 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "IoT-Simulator"] path = IoT-Simulator url = https://repositories.communitynotfound.work/PoliBa-Software-Architecture/IoT-Simulator.git +[submodule "Leader-Service"] + path = Leader-Service + url = https://repositories.communitynotfound.work/PoliBa-Software-Architecture/Leader-Service.git diff --git a/Leader-Service b/Leader-Service new file mode 160000 index 0000000..d44865d --- /dev/null +++ b/Leader-Service @@ -0,0 +1 @@ +Subproject commit d44865db427d26b9af8702238e649b93bea7a841 diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..035e9db --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,45 @@ +name: "IoT-Gatherer-Project" + +services: + iot-simulator: + image: "swift:latest" + volumes: + - .:/workspace + hostname: iot-simulator.internal + networks: + iot-network: + ipv4_address: 10.0.0.15 + command: sleep infinity + + leader-service: + image: denoland/deno + volumes: + - .:/workspace + hostname: leader-service.internal + networks: + iot-network: + ipv4_address: 10.0.0.2 + command: sleep infinity + + nginx-mediator: + image: "nginx:latest" + volumes: + - .:/workspace + - ./nginx/proxy.conf:/etc/nginx/nginx.conf + hostname: nginx-mediator.internal + networks: + iot-network: + ipv4_address: 10.0.0.10 + command: sleep infinity + +networks: + iot-network: + ipam: + config: + - subnet: 10.0.0.0/8 + ip_range: 10.0.0.0/16 + + + + + diff --git a/nginx/proxy.conf b/nginx/proxy.conf new file mode 100644 index 0000000..3e3ea0c --- /dev/null +++ b/nginx/proxy.conf @@ -0,0 +1,33 @@ +http { + + # Leader-Service-Proxy + server { + # TODO: Change IP to a well defined one + listen *:80; # This is for testing purposes ONLY, to be changed to 443 + server_name "nginx-mediator.internal"; + + location / { + + proxy_pass "http://leader-service.internal"; + proxy_pass_request_headers on; + proxy_pass_request_body on; + + proxy_set_header X-Forwarded-For $sent_http_x_iot_ip; # X-IoT-IP + } + } + + # IoT-Simulator Proxy + server { + listen *:80; # This is for testing purposes ONLY, to be changed to 443 + + location / { + + proxy_pass "http://iot-simulator.internal"; + proxy_pass_request_headers on; + proxy_pass_request_body on; + + proxy_set_header X-Forwarded-Host $sent_http_x_iot_ip; # Set forwarded host to keep the original IP request + + } + } +} \ No newline at end of file