# 保险智能客服系统 — Nginx 反向代理配置 # 所有服务通过 Nginx 统一入口对外 upstream insurance_api_upstream { server baodan-api:5001; keepalive 64; } upstream baodan_core_api_upstream { server baodan-core-api:5001; keepalive 64; } server { listen 80; server_name your-domain.com; # ---- 你的 Vue 前端 ---- location / { proxy_pass http://frontend:80; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } # ---- SSE 流式响应(必须使用真实 /insurance 路径)---- location = /insurance/chat/message { proxy_pass http://insurance_api_upstream; proxy_http_version 1.1; proxy_set_header Connection ""; 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_buffering off; proxy_cache off; gzip off; proxy_read_timeout 300s; proxy_send_timeout 300s; add_header X-Accel-Buffering no; } # ---- Insurance 普通 API ---- location /insurance/ { proxy_pass http://insurance_api_upstream; proxy_http_version 1.1; proxy_set_header Connection ""; 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; } # ---- BaoDan Core API(与 Insurance SSE 进程池隔离)---- location /api/ { proxy_pass http://baodan_core_api_upstream/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_read_timeout 120s; proxy_buffering off; } # ---- BaoDan WebApp(对话 iframe 嵌入)---- location /chat/ { proxy_pass http://baodan-web:3000/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } # ---- BaoDan API(v1 路径,Workflow/RAG 等)---- location /v1/ { proxy_pass http://baodan_core_api_upstream/v1/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } # ---- 企微回调(需要较长超时)---- location /api/wecom/callback { proxy_pass http://baodan-api:5001/api/wecom/callback; proxy_read_timeout 120s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } # 静态资源缓存 location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ { proxy_pass http://frontend:80; expires 30d; add_header Cache-Control "public, immutable"; } } # HTTPS(生产环境取消注释) # server { # listen 443 ssl http2; # server_name your-domain.com; # ssl_certificate /etc/ssl/your-domain.com.pem; # ssl_certificate_key /etc/ssl/your-domain.com.key; # # # 同上 location 配置... # }