# nginx/nginx.conf — Clover 反向代理配置
# SSE 端点需关闭 proxy_buffering 才能实时透传

server {
    listen 80;
    server_name _;

    # ── SSE 端点：关闭缓冲，实时透传 ──────────────────
    location ~* /api/v1/tasks/[^/]+/stream {
        proxy_pass         http://api:8000;
        proxy_http_version 1.1;
        proxy_set_header   Connection "";
        proxy_buffering    off;
        proxy_cache        off;
        proxy_read_timeout 3600s;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Authorization $http_authorization;
    }

    # ── 普通 API 端点 ──────────────────────────────────
    location /api/ {
        proxy_pass         http://api:8000;
        proxy_http_version 1.1;
        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   Authorization $http_authorization;
        client_max_body_size 20m;
    }

    # ── 健康检查 ───────────────────────────────────────
    location /health {
        proxy_pass http://api:8000/health;
    }
}
