# /etc/nginx/conf.d/ai-services.conf
server {
    listen 80;
    server_name localhost;

    # 服务1：文本分类（网关路径/ai/text-classify）
    location /ai/text-classify/ {
        proxy_pass http://text-classification: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_connect_timeout 30s;
        proxy_read_timeout 30s;
    }

    # 服务2：图像识别（网关路径/ai/image-recog）
    location /ai/image-recog/ {
        proxy_pass http://image-recognition: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_connect_timeout 30s;
        proxy_read_timeout 30s;
    }

    # 服务3：语音转文字（网关路径/ai/speech-to-text）
    location /ai/speech-to-text/ {
        proxy_pass http://speech-to-text: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_connect_timeout 30s;
        proxy_read_timeout 30s;
    }

    # OpenAI代理服务（网关路径/ai/openai）
    location /ai/openai/ {
        proxy_pass http://openai-proxy: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_connect_timeout 30s;
        proxy_read_timeout 30s;
    }

    # 后端服务（网关路径/api）
    location /api/ {
        proxy_pass http://backend: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_connect_timeout 30s;
        proxy_read_timeout 30s;
    }

    # 健康检查
    location /health {
        return 200 'OK';
    }
}
