fix(nginx): WebSocket upgrade dla Grafana Live + ujednolicenie mapą#3
Merged
Conversation
…ic mapa Blok `location /grafana/` jako jedyny proxy nie ustawial naglowkow upgrade'u WebSocketu, wiec Grafana Live (`wss://<host>/grafana/api/live/ws`) leciala w NS_ERROR_WEBSOCKET_CONNECTION_REFUSED — nginx degradowal polaczenie do HTTP/1.0 i handshake byl odrzucany. Dodano proxy_http_version 1.1 + Upgrade/Connection. Przy okazji ujednolicono wszystkie cztery bloki proxy (appserver, grafana, dozzle, netdata): zahardkodowane `Connection "upgrade"` zastapione przez `Connection $connection_upgrade` z mapa http-context w default.conf.template. Dla nie-WS requestow wysylamy teraz `Connection: close` zamiast mylacego `upgrade` (keep-alive nie jest psuty), zachowujac upgrade dla realnego WS. Mapa zyje w default.conf.template (kontekst http, wspoldzielony przez vhosty). $http_upgrade/$connection_upgrade nie sa zmiennymi srodowiska, wiec envsubst ich nie podmienia. Testy nginx -t montuja default.conf.template, wiec mapa renderuje sie i zmienna rozwiazuje sie w blokach proxy. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
W Firefoksie (i każdej przeglądarce) na
https://<host>/grafana/:Grafana Live trzyma stałe połączenie WebSocket na
/grafana/api/live/ws. Bloklocation /grafana/w_bpp-locations.confbył jedynym proxy bez nagłówków upgrade'u — nginx degradował połączenie do HTTP/1.0 i odrzucał handshake. Bloki Dozzle i Netdata miały to od początku, Grafana została pominięta.Zmiana
proxy_http_version 1.1+Upgrade/Connectiondo bloku Grafany.@proxy_to_app, grafana, dozzle, netdata) używały zahardkodowanegoConnection "upgrade". Zastąpione przezConnection $connection_upgradez mapą http-context wdefault.conf.template:Dla zwykłych (nie-WS) requestów wysyłamy teraz
Connection: closezamiast mylącegoupgrade, zachowującupgradedla realnego WebSocketu.Uwagi
default.conf.template(konteksthttp, współdzielony przez wszystkie vhosty).$http_upgrade/$connection_upgradenie są zmiennymi środowiska, więc20-envsubst-on-templates.shich nie podmienia — przetrwają jako zmienne runtime nginx.nginx -t(tests/test_makefile.sh, Test 14/15) montujądefault.conf.template, więc mapa renderuje się do http-context i$connection_upgraderozwiązuje się w blokach proxy — bez tegonginx -trzuciłbyunknown "connection_upgrade" variable.Wdrożenie po merge
_bpp-locations.confidefault.conf.templatesą bind-mountowane wprost z repo, aledefault.conf.templaterenderuje entrypoint przy starcie. Żeby mapa trafiła do configu, potrzebny recreate webservera (samnginx -s reloadnie przerenderuje template'u):git pull docker compose up -d webserver # re-render default.conf.template (mapa) + pickup _bpp-locations.conf🤖 Generated with Claude Code