From 4aa56877b261eddeeb74a57676b66eab8f2dae70 Mon Sep 17 00:00:00 2001 From: Oindrila Banerjee Date: Wed, 15 Oct 2025 21:48:39 +0530 Subject: [PATCH 1/4] build: XYN-198 Modified docker compose and nginx config Modified docker compose and nginx config to reverse proxy grafana --- .../docker-compose.infrastructure-cpu.yml | 1 + .../docker-compose.infrastructure.yml | 1 + deployment/portable/nginx.conf | 27 +++++++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/deployment/portable/docker-compose.infrastructure-cpu.yml b/deployment/portable/docker-compose.infrastructure-cpu.yml index 05f4a6f5e..2ec463116 100644 --- a/deployment/portable/docker-compose.infrastructure-cpu.yml +++ b/deployment/portable/docker-compose.infrastructure-cpu.yml @@ -49,6 +49,7 @@ services: environment: - POSTGRES_USER=xyne - POSTGRES_PASSWORD=xyne + - GF_SERVER_ROOT_URL=%(protocol)s://%(domain)s:%(http_port)s/grafana vespa: image: vespaengine/vespa:latest diff --git a/deployment/portable/docker-compose.infrastructure.yml b/deployment/portable/docker-compose.infrastructure.yml index 6500d9e3f..36d91f2da 100644 --- a/deployment/portable/docker-compose.infrastructure.yml +++ b/deployment/portable/docker-compose.infrastructure.yml @@ -49,6 +49,7 @@ services: environment: - POSTGRES_USER=xyne - POSTGRES_PASSWORD=xyne + - GF_SERVER_ROOT_URL=%(protocol)s://%(domain)s:%(http_port)s/grafana vespa: image: xyne-vespa-gpu diff --git a/deployment/portable/nginx.conf b/deployment/portable/nginx.conf index da52370da..153a9e108 100644 --- a/deployment/portable/nginx.conf +++ b/deployment/portable/nginx.conf @@ -80,6 +80,12 @@ http { keepalive 8; } + # Grafana backend + upstream grafana_backend { + server xyne-grafana:3000; + keepalive 16; + } + # Main HTTP server server { listen 80; @@ -201,8 +207,8 @@ http { access_log off; } - # Static files with caching - location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + # Static files with caching (excluding Grafana paths) + location ~* ^/(?!grafana/).*\.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { proxy_pass http://app_backend; proxy_http_version 1.1; proxy_set_header Host $host; @@ -215,5 +221,22 @@ http { add_header Cache-Control "public, immutable"; access_log off; } + + # Redirect /grafana to /grafana/ + location = /grafana { + return 302 /grafana/; + } + + # Grafana routes (must come after static files to ensure proper handling) + location /grafana/ { + proxy_pass http://grafana_backend/; + 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; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + } } } \ No newline at end of file From 2a05b73291e382c0fbbf1cea182911397e14afff Mon Sep 17 00:00:00 2001 From: Oindrila Banerjee Date: Wed, 15 Oct 2025 21:48:39 +0530 Subject: [PATCH 2/4] build: XYN-198 Modified docker compose and nginx config Modified docker compose and nginx config to reverse proxy grafana --- .../docker-compose.infrastructure-cpu.yml | 1 + .../docker-compose.infrastructure.yml | 1 + deployment/portable/nginx.conf | 27 +++++++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/deployment/portable/docker-compose.infrastructure-cpu.yml b/deployment/portable/docker-compose.infrastructure-cpu.yml index 05f4a6f5e..2ec463116 100644 --- a/deployment/portable/docker-compose.infrastructure-cpu.yml +++ b/deployment/portable/docker-compose.infrastructure-cpu.yml @@ -49,6 +49,7 @@ services: environment: - POSTGRES_USER=xyne - POSTGRES_PASSWORD=xyne + - GF_SERVER_ROOT_URL=%(protocol)s://%(domain)s:%(http_port)s/grafana vespa: image: vespaengine/vespa:latest diff --git a/deployment/portable/docker-compose.infrastructure.yml b/deployment/portable/docker-compose.infrastructure.yml index cfc0f151c..e7e5efa1c 100644 --- a/deployment/portable/docker-compose.infrastructure.yml +++ b/deployment/portable/docker-compose.infrastructure.yml @@ -49,6 +49,7 @@ services: environment: - POSTGRES_USER=xyne - POSTGRES_PASSWORD=xyne + - GF_SERVER_ROOT_URL=%(protocol)s://%(domain)s:%(http_port)s/grafana vespa: image: xyne-vespa-gpu diff --git a/deployment/portable/nginx.conf b/deployment/portable/nginx.conf index da52370da..153a9e108 100644 --- a/deployment/portable/nginx.conf +++ b/deployment/portable/nginx.conf @@ -80,6 +80,12 @@ http { keepalive 8; } + # Grafana backend + upstream grafana_backend { + server xyne-grafana:3000; + keepalive 16; + } + # Main HTTP server server { listen 80; @@ -201,8 +207,8 @@ http { access_log off; } - # Static files with caching - location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + # Static files with caching (excluding Grafana paths) + location ~* ^/(?!grafana/).*\.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { proxy_pass http://app_backend; proxy_http_version 1.1; proxy_set_header Host $host; @@ -215,5 +221,22 @@ http { add_header Cache-Control "public, immutable"; access_log off; } + + # Redirect /grafana to /grafana/ + location = /grafana { + return 302 /grafana/; + } + + # Grafana routes (must come after static files to ensure proper handling) + location /grafana/ { + proxy_pass http://grafana_backend/; + 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; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + } } } \ No newline at end of file From 503e32f2492c4c123ea5c1d9401dfa9c40a99f23 Mon Sep 17 00:00:00 2001 From: Oindrila Banerjee Date: Thu, 16 Oct 2025 10:41:35 +0530 Subject: [PATCH 3/4] refactor: XYN-198 Made changes WRT PR Comments --- deployment/portable/docker-compose.infrastructure-cpu.yml | 2 +- deployment/portable/docker-compose.infrastructure.yml | 2 +- deployment/portable/nginx.conf | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deployment/portable/docker-compose.infrastructure-cpu.yml b/deployment/portable/docker-compose.infrastructure-cpu.yml index 2ec463116..70b9ba063 100644 --- a/deployment/portable/docker-compose.infrastructure-cpu.yml +++ b/deployment/portable/docker-compose.infrastructure-cpu.yml @@ -42,7 +42,7 @@ services: - ./grafana/provisioning:/etc/grafana/provisioning - ${XYNE_DATA_DIR:-./data}/grafana-storage:/var/lib/grafana ports: - - "3002:3000" + - "3000" restart: always networks: - xyne diff --git a/deployment/portable/docker-compose.infrastructure.yml b/deployment/portable/docker-compose.infrastructure.yml index e7e5efa1c..36419f434 100644 --- a/deployment/portable/docker-compose.infrastructure.yml +++ b/deployment/portable/docker-compose.infrastructure.yml @@ -42,7 +42,7 @@ services: - ./grafana/provisioning:/etc/grafana/provisioning - ${XYNE_DATA_DIR:-./data}/grafana-storage:/var/lib/grafana ports: - - "3002:3000" + - "3000" restart: always networks: - xyne diff --git a/deployment/portable/nginx.conf b/deployment/portable/nginx.conf index 153a9e108..7a6f0a354 100644 --- a/deployment/portable/nginx.conf +++ b/deployment/portable/nginx.conf @@ -84,7 +84,7 @@ http { upstream grafana_backend { server xyne-grafana:3000; keepalive 16; - } + } # Main HTTP server server { @@ -224,7 +224,7 @@ http { # Redirect /grafana to /grafana/ location = /grafana { - return 302 /grafana/; + return 301 /grafana/; } # Grafana routes (must come after static files to ensure proper handling) @@ -239,4 +239,4 @@ http { proxy_set_header Connection $connection_upgrade; } } -} \ No newline at end of file +} From 17921d2c450d7ac529b1d709414a228fb25d529e Mon Sep 17 00:00:00 2001 From: Oindrila Banerjee Date: Thu, 16 Oct 2025 15:28:08 +0530 Subject: [PATCH 4/4] refactor: XYNE-198 Made changes WRT PR comment --- deployment/portable/nginx.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/deployment/portable/nginx.conf b/deployment/portable/nginx.conf index 7a6f0a354..3a1702ba0 100644 --- a/deployment/portable/nginx.conf +++ b/deployment/portable/nginx.conf @@ -237,6 +237,10 @@ http { proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; + proxy_cache_bypass $http_upgrade; + proxy_read_timeout 300; + proxy_connect_timeout 30; + proxy_send_timeout 300; } } }