trading/docker/nginx-k8s.conf
Viktor Barzin 9f86aaf540
add K8s nginx config and parameterize Dockerfile.dashboard
Create nginx-k8s.conf that proxies to localhost:8000 instead of
api-gateway:8000 for K8s pods where both containers share a network
namespace. Update Dockerfile.dashboard to accept a NGINX_CONF build arg
(defaults to docker/nginx.conf for docker-compose compatibility).
2026-02-23 22:27:52 +00:00

77 lines
3.2 KiB
Text

# nginx configuration for the trading-bot dashboard (Kubernetes variant).
# Serves the React SPA and proxies API / WebSocket requests to the api-gateway.
# In K8s both containers share a pod, so the upstream is localhost instead of
# the Docker Compose service hostname "api-gateway".
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# ---------------------------------------------------------------------------
# SPA: serve index.html for any path not matching a static file
# ---------------------------------------------------------------------------
location / {
try_files $uri $uri/ /index.html;
}
# ---------------------------------------------------------------------------
# Proxy /api/auth/* to the api-gateway /auth/* routes
# (Dashboard client uses baseURL=/api, so auth calls arrive as /api/auth/*)
# ---------------------------------------------------------------------------
location /api/auth/ {
proxy_pass http://localhost:8000/auth/;
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 /api/* to the api-gateway service
# ---------------------------------------------------------------------------
location /api/ {
proxy_pass http://localhost:8000/api/;
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 /auth/* to the api-gateway service
# ---------------------------------------------------------------------------
location /auth/ {
proxy_pass http://localhost:8000;
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 /health to the api-gateway service
# ---------------------------------------------------------------------------
location /health {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# ---------------------------------------------------------------------------
# WebSocket upgrade for /ws
# ---------------------------------------------------------------------------
location /ws {
proxy_pass http://localhost: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_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 86400;
}
}