From f6eab3c5cb3f77943020ffb938b4c07ac98b5e20 Mon Sep 17 00:00:00 2001 From: fhs52267 Date: Sun, 22 Mar 2026 15:47:55 +0100 Subject: [PATCH] Add internal reverse proxy --- meshmonitor/Dockerfile | 4 +++- meshmonitor/config.yaml | 11 +++++------ meshmonitor/nginx.conf | 16 ++++++++++++++++ meshmonitor/run.sh | 15 ++++++++++++++- 4 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 meshmonitor/nginx.conf diff --git a/meshmonitor/Dockerfile b/meshmonitor/Dockerfile index 64ee4ac..5699dac 100644 --- a/meshmonitor/Dockerfile +++ b/meshmonitor/Dockerfile @@ -1,7 +1,9 @@ FROM ghcr.io/yeraze/meshmonitor:latest USER root -RUN apk add --no-cache jq curl bash +RUN apk add --no-cache jq curl bash nginx + +COPY nginx.conf /etc/nginx/http.d/default.conf COPY run.sh /run.sh RUN chmod a+x /run.sh diff --git a/meshmonitor/config.yaml b/meshmonitor/config.yaml index cf7db60..b2f76ac 100644 --- a/meshmonitor/config.yaml +++ b/meshmonitor/config.yaml @@ -1,15 +1,14 @@ name: "MeshMonitor" description: "Meshtastic Monitoring Dashboard" -version: "1.0.5" +version: "1.0.6" slug: "meshmonitor" arch: - aarch64 - amd64 -# Remove the ingress keys entirely -ports: - 3001/tcp: 8080 -ports_description: - 3001/tcp: "Web Interface" +ingress: true +ingress_port: 8099 +panel_icon: mdi:access-point-network +panel_title: "MeshMonitor" options: MESHTASTIC_NODE_IP: "192.168.1.100" MESHTASTIC_TCP_PORT: 4403 diff --git a/meshmonitor/nginx.conf b/meshmonitor/nginx.conf new file mode 100644 index 0000000..b531933 --- /dev/null +++ b/meshmonitor/nginx.conf @@ -0,0 +1,16 @@ +server { + listen 8099; + + location / { + # Reconstruct the full path expected by the app's BASE_URL + proxy_pass http://127.0.0.1:3001$http_x_ingress_path$request_uri; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} \ No newline at end of file diff --git a/meshmonitor/run.sh b/meshmonitor/run.sh index 2017b40..8be3378 100644 --- a/meshmonitor/run.sh +++ b/meshmonitor/run.sh @@ -8,7 +8,20 @@ export DISABLE_ANONYMOUS=$(jq --raw-output '.DISABLE_ANONYMOUS' $CONFIG_PATH) export DATABASE_PATH="/data/meshmonitor.db" export PORT=3001 +export TRUST_PROXY=true export ALLOWED_ORIGINS="*" +export COOKIE_SECURE=false -echo "Starting MeshMonitor for node: $MESHTASTIC_NODE_IP..." +# Fetch Ingress URL so the Node app knows its subpath +if [ -n "$SUPERVISOR_TOKEN" ]; then + RAW_URL=$(curl -s -H "Authorization: Bearer ${SUPERVISOR_TOKEN}" http://supervisor/addons/self/info | jq --raw-output '.data.ingress_url') + export BASE_URL="${RAW_URL%/}" + echo "Configuring MeshMonitor BASE_URL to: $BASE_URL" +fi + +# Start Nginx in the background +mkdir -p /run/nginx +nginx + +echo "Starting MeshMonitor..." exec node dist/server/server.js \ No newline at end of file