Serve /api/ws without Basic auth so the live feed connects
Browsers don't reliably replay Basic-auth credentials on a WebSocket upgrade, so the dashboard's live feed was stuck on "reconnecting" (only the 5s REST poll worked). Give /api/ws a higher-priority Traefik router that skips Basic auth; the backend still requires API_TOKEN, which nginx injects on the handshake. The deploy now fails closed unless CRYPTO_API_TOKEN is set. Also: split the nginx /api/ws block so upgrade headers are only set there, and add reconnect backoff (2s -> 30s) so a failing socket stops hammering.
This commit is contained in:
1 parent
97fbd5901e
commit
3e19612cc0
7 files changed
+101
-4
No files matched your search
+14
-1
@@ -8,7 +8,10 @@ server {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
# WebSocket feed. Kept in its own block so the upgrade headers are only set
|
||||
# here, and so the API token is injected server-side on the handshake (the
|
||||
# browser cannot set headers on a WebSocket).
|
||||
location /api/ws {
|
||||
proxy_pass http://backend:8000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
@@ -16,6 +19,16 @@ server {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_set_header ${API_TOKEN_HEADER} "${API_TOKEN}";
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://backend:8000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_read_timeout 3600s;
|
||||
# Inject the optional API token server-side so the browser never sees it
|
||||
# and the WebUI keeps working without any client changes.
|
||||
proxy_set_header ${API_TOKEN_HEADER} "${API_TOKEN}";
|
||||
|
||||
Reference in new issue
Block a user