# Nginx 配置片段 - 添加到 valuefrontier.conf 的 HTTPS server 块中 # 将这些配置添加到 443 端口的 server 块中,在其他 location 配置之前 # ============================================ # AI Chat 应用 (Next.js) # ============================================ # AgentChat 应用代理 - 使用新路径避免与现有 /chat/ 冲突 location /ai-chat { # 重写路径,去掉 /ai-chat 前缀 rewrite ^/ai-chat(.*)$ $1 break; proxy_pass http://127.0.0.1:3000; 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 X-Forwarded-Proto $scheme; # 保持 Cookie 传递(重要:Session 共享) proxy_set_header Cookie $http_cookie; proxy_pass_request_headers on; # WebSocket 支持(如果需要实时功能) proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; # 禁用缓冲,支持流式响应 proxy_buffering off; proxy_cache off; # 超时设置 proxy_connect_timeout 60s; proxy_send_timeout 300s; proxy_read_timeout 300s; } # Next.js 静态资源 location ~ ^/ai-chat/(_next|__nextjs) { rewrite ^/ai-chat(.*)$ $1 break; proxy_pass http://127.0.0.1:3000; 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 X-Forwarded-Proto $scheme; # 静态资源缓存 expires 1y; add_header Cache-Control "public, immutable"; } # MCP API 已经配置在 /mcp/ 路径 (保持不变) # location /mcp/ { ... } # 已存在,无需修改