Files
vf_react/nginx-update.sh
2025-11-22 09:10:13 +08:00

79 lines
2.4 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Nginx 配置更新脚本
# 在 HTTPS server 块中添加 AgentChat 代理配置
echo "========================================="
echo "Nginx 配置更新 - 添加 AgentChat 代理"
echo "========================================="
# 备份原配置
echo "1. 备份原配置文件..."
sudo cp /etc/nginx/sites-available/valuefrontier /etc/nginx/sites-available/valuefrontier.backup.$(date +%Y%m%d_%H%M%S)
echo "2. 添加 AgentChat 配置..."
echo ""
echo "请在 valuefrontier.conf 的 HTTPS server 块中(大约第 228 行chat/ 配置之前)添加以下内容:"
echo ""
cat << 'EOF'
# ============================================
# AI Chat 应用 (Next.js) - MCP 集成
# ============================================
# AgentChat 应用代理
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;
# 静态资源缓存
expires 1y;
add_header Cache-Control "public, immutable";
}
EOF
echo ""
echo "3. 编辑配置文件:"
echo " sudo nano /etc/nginx/sites-available/valuefrontier"
echo ""
echo "4. 在第 227 行location /chat/ { 之前)插入上述配置"
echo ""
echo "5. 保存并测试配置:"
echo " sudo nginx -t"
echo ""
echo "6. 如果测试通过,重载 Nginx"
echo " sudo nginx -s reload"
echo ""
echo "========================================="