- Make all AI endpoints (health scores + investment recommendations) fire-and-forget: POST returns immediately, frontend polls for results - Extend AI API timeout from 2-5 min to 10 min for both services - Add "last analysis failed — showing cached data" message to the Investment Recommendations panel (matches health score widgets) - Add status/error_message columns to ai_recommendations table - Remove nginx AI timeout overrides (no longer needed) - Users can now navigate away during AI processing without interruption Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
54 lines
1.4 KiB
Plaintext
54 lines
1.4 KiB
Plaintext
upstream backend {
|
|
server backend:3000;
|
|
keepalive 32; # reuse connections to backend
|
|
}
|
|
|
|
upstream frontend {
|
|
server frontend:3001;
|
|
keepalive 16;
|
|
}
|
|
|
|
# Shared proxy settings
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection ""; # enable keepalive to upstreams
|
|
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;
|
|
|
|
# Buffer settings — prevent 502s when backend is slow to respond
|
|
proxy_buffering on;
|
|
proxy_buffer_size 16k;
|
|
proxy_buffers 8 16k;
|
|
proxy_busy_buffers_size 32k;
|
|
|
|
# Rate limit zone (10 req/s per IP for API)
|
|
limit_req_zone $binary_remote_addr zone=api_limit:10m rate=10r/s;
|
|
|
|
# HTTP server — SSL termination is handled by the host reverse proxy
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
# --- API routes → backend ---
|
|
location /api/ {
|
|
limit_req zone=api_limit burst=30 nodelay;
|
|
|
|
proxy_pass http://backend;
|
|
proxy_read_timeout 30s;
|
|
proxy_connect_timeout 5s;
|
|
proxy_send_timeout 15s;
|
|
}
|
|
|
|
# AI endpoints now return immediately (async processing in background)
|
|
# No special timeout overrides needed
|
|
|
|
# --- Static frontend → built React assets ---
|
|
location / {
|
|
proxy_pass http://frontend;
|
|
proxy_read_timeout 10s;
|
|
proxy_connect_timeout 5s;
|
|
proxy_cache_bypass $http_upgrade;
|
|
}
|
|
}
|