diff --git a/README.md b/README.md index 67ba783..a91582e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ When the GUI is not installed and it is requested, the terminal will auto login The historical data is stored locally in a SQLite database which is managed by a Python Flask API. It can be viewed on a web dashboard at port 80. -There is a live dashboard of currently attched drives on port 3000. This will show all attached drives along with the health data for these drives. This uses a websocket to live-update the data. The catch is I haven't learned how to mix PHP and Node.js sites yet, thus the multiple ports. It sounds to me like the next part of this project is another web server container that is a proxy with both pages. That does not exist yet. +The live dashboard is at the root, and the history is at /history, thanks nginx. There may be issues with some of the status commands due to hardware differences. I have only found an issue when using the NanoPi devices and have included the corrected string. journalctl is your friend, get to know it. diff --git a/files/dashboard/index.php b/files/dashboard/index.php index 1bafe84..21a473e 100644 --- a/files/dashboard/index.php +++ b/files/dashboard/index.php @@ -29,11 +29,12 @@ function fetchSSDData() {
-

- This lists every disk ever scanned by this device.
- - this link.

"; +
+ This is a historical list of every disk ever scanned by this device.

+ For a live dashboard, please visit home. +

+
+ '; diff --git a/files/dashboard/styles.css b/files/dashboard/styles.css index f362362..e35261a 100644 --- a/files/dashboard/styles.css +++ b/files/dashboard/styles.css @@ -16,12 +16,10 @@ body { background-color: #34495e; border: none; color: white; - padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; - margin: 4px 2px; cursor: pointer; } diff --git a/files/nginx/nginx.conf b/files/nginx/nginx.conf new file mode 100644 index 0000000..59860b4 --- /dev/null +++ b/files/nginx/nginx.conf @@ -0,0 +1,39 @@ +# nginx.conf +# This file will be mounted into /etc/nginx/conf.d/default.conf inside the container + +# Enable proxy buffers (optional but recommended) +proxy_buffering on; +proxy_buffers 16 16k; +proxy_buffer_size 32k; + +server { +listen 80; +server_name localhost; + +# -------------------------------------------------------------------- +# Proxy everything under "/" to the Node backend +# -------------------------------------------------------------------- +location / { + proxy_pass http://172.17.0.1:3000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; +} + +# -------------------------------------------------------------------- +# Proxy everything under "/history" to the Apache backend +# -------------------------------------------------------------------- +location /history/ { + proxy_pass http://172.17.0.1:8080/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; +} + +# Optional: If you want `/history` (without trailing slash) to be +# redirected to `/history/`: +location = /history { + return 301 /history/; +} +} + \ No newline at end of file diff --git a/files/ws_node/public/index.html b/files/ws_node/public/index.html index 8671407..4239664 100644 --- a/files/ws_node/public/index.html +++ b/files/ws_node/public/index.html @@ -8,6 +8,11 @@ +
+

Live Dashboard

+ This dashboard shows the currently attached drives along with their health status.

+ For a history of all drives attached, you can visit here. +

Attached Disks

Connecting…
diff --git a/tasks/dashboard.yaml b/tasks/dashboard.yaml index dcf41fd..aa5b687 100644 --- a/tasks/dashboard.yaml +++ b/tasks/dashboard.yaml @@ -16,7 +16,7 @@ owner: root group: root -- name: drive history dashboard - copy files for docker container +- name: drive history dashboard - copy files for history dashboard copy: src: "dashboard/" dest: "{{ service_control_web_folder }}/html" @@ -24,6 +24,14 @@ owner: root group: root +- name: drive history dashboard - copy files for proxy container + copy: + src: "nginx/" + dest: "{{ service_control_web_folder }}/proxy" + mode: 0755 + owner: root + group: root + - name: websocket tasks when: not quick_refresh | bool block: diff --git a/templates/docker-compose.yaml b/templates/docker-compose.yaml index ef90209..0c1fd19 100644 --- a/templates/docker-compose.yaml +++ b/templates/docker-compose.yaml @@ -4,7 +4,7 @@ services: container_name: web_dash image: php:8.0-apache ports: - - 80:80 + - 172.17.0.1:8080:80 volumes: - ./html:/var/www/html/ network_mode: bridge @@ -14,15 +14,30 @@ services: container_name: ws_node image: ws_node ports: - - 3000:3000 + - 172.17.0.1:3000:3000 network_mode: bridge restart: always depends_on: - redis redis: + container_name: redis image: redis:7-alpine + ports: + - 172.17.0.1:6379:6379 network_mode: bridge restart: always + + nginx_proxy: + container_name: nginx_proxy + image: nginx:latest ports: - - 172.17.0.1:6379:6379 \ No newline at end of file + - "80:80" + volumes: + - ./proxy/nginx.conf:/etc/nginx/conf.d/default.conf + network_mode: bridge + restart: always + depends_on: + - web_dash + - ws_node +