From 09f1fb958da8101bb05fa821035c395cbf015948 Mon Sep 17 00:00:00 2001 From: Mohamed jameel alabasy Date: Sat, 2 May 2026 11:43:16 +0300 Subject: [PATCH] Add reverse-proxy routes for API, WS, Grafana Add Nginx location blocks to proxy /api/ to localhost:8080, /socket.io/ to localhost:8080 with WebSocket upgrade headers, and /grafana/ to localhost:3000. Configure common proxy headers (Host, X-Real-IP, X-Forwarded-For/Proto) and keep the existing SPA fallback for /. Grafana block includes a "MUST KEEP" note. --- nginx/rythmify.duckdns.org.conf | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/nginx/rythmify.duckdns.org.conf b/nginx/rythmify.duckdns.org.conf index 1596af0..2f33897 100644 --- a/nginx/rythmify.duckdns.org.conf +++ b/nginx/rythmify.duckdns.org.conf @@ -19,6 +19,37 @@ server { root /var/www/rythmify; index index.html; + # Backend API + location /api/ { + proxy_pass http://localhost:8080/api/; + + 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; + } + + # WebSocket support + location /socket.io/ { + proxy_pass http://localhost:8080/socket.io/; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + } + + # Grafana (MUST KEEP) + 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; + } + + # Frontend SPA location / { try_files $uri $uri/ /index.html; }