From a5df78403fd256a3f229df38188694fed0b9b06e Mon Sep 17 00:00:00 2001 From: Mohamed jameel alabasy Date: Sat, 2 May 2026 11:59:47 +0300 Subject: [PATCH] Fix Grafana URL; add /health and proxy tweaks Update GF_SERVER_ROOT_URL to use rythmify.duckdns.org (remove -back) and enhance nginx routing: add a /health proxy to the backend, add a redirect for /grafana -> /grafana/, and include WebSocket (Upgrade/Connection) and standard proxy headers for the Grafana proxy. These changes ensure health checks work, Grafana assets and WebSocket connections function correctly, and the reported root URL matches the public hostname. --- docker-compose.monitoring.yml | 2 +- nginx/rythmify.duckdns.org.conf | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/docker-compose.monitoring.yml b/docker-compose.monitoring.yml index ab5eecd..d255730 100644 --- a/docker-compose.monitoring.yml +++ b/docker-compose.monitoring.yml @@ -70,7 +70,7 @@ services: GF_SMTP_FROM_NAME: ${GF_SMTP_FROM_NAME:-Rythmify Monitoring} GF_SMTP_STARTTLS_POLICY: MandatoryStartTLS ALERT_EMAIL_TO: ${ALERT_EMAIL_TO:-} - GF_SERVER_ROOT_URL: https://rythmify-back.duckdns.org/grafana/ + GF_SERVER_ROOT_URL: https://rythmify.duckdns.org/grafana/ GF_SERVER_SERVE_FROM_SUB_PATH: "true" volumes: - grafana_data:/var/lib/grafana diff --git a/nginx/rythmify.duckdns.org.conf b/nginx/rythmify.duckdns.org.conf index 2f33897..03e20e6 100644 --- a/nginx/rythmify.duckdns.org.conf +++ b/nginx/rythmify.duckdns.org.conf @@ -19,6 +19,16 @@ server { root /var/www/rythmify; index index.html; + location /health { + proxy_pass http://localhost:8080/health; + + proxy_http_version 1.1; + 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_set_header X-Forwarded-Proto $scheme; + } + # Backend API location /api/ { proxy_pass http://localhost:8080/api/; @@ -40,13 +50,22 @@ server { proxy_set_header Host $host; } - # Grafana (MUST KEEP) + # Handle missing trailing slash + location = /grafana { + return 301 /grafana/; + } + + # Grafana proxy location /grafana/ { proxy_pass http://localhost:3000/; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; + + # Required for Grafana WebSockets + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; } # Frontend SPA