Files
crypto_trading/frontend/nginx.conf
T
matitos c63753e592
CI/CD / backend (pull_request) Successful in 5m41s
CI/CD / frontend (pull_request) Successful in 5m18s
CI/CD / build (pull_request) Skipped
CI/CD / deploy (pull_request) Skipped
CI/CD / cleanup (pull_request) Skipped
Stop caching index.html and speed up socket reconnect
Phones offer no easy hard-refresh, so a cached index.html kept serving an old
bundle after a deploy (the live feed showed "reconnecting"). index.html and the
SPA catch-all now send Cache-Control: no-store, while hashed /assets stay
immutable. Also retry the first socket reconnect after 1s (was 2s) and surface
the close code in the header so a failure is actionable on a phone.
2026-09-19 23:52:54 +00:00

52 lines
1.7 KiB
Nginx Configuration File

server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Hashed Vite assets are immutable; cache them hard.
location /assets/ {
add_header Cache-Control "public, max-age=31536000, immutable";
try_files $uri =404;
}
# The HTML entry point must never be cached, or a phone (which offers no
# easy hard-refresh) keeps loading an old bundle after a deploy. The
# catch-all serves index.html for client-side routes, so it gets the same
# no-store header.
location = /index.html {
add_header Cache-Control "no-store";
}
location / {
add_header Cache-Control "no-store";
try_files $uri $uri/ /index.html;
}
# WebSocket feed. Kept in its own block so the upgrade headers are only set
# here, and so the optional 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;
proxy_set_header Connection "upgrade";
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}";
}
}