From b64ade0525c0520655899279cb05e5320e9566f3 Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Wed, 11 Mar 2026 20:39:05 +0800 Subject: [PATCH] bug fix --- .gitignore | 1 + backend/Dockerfile | 15 +++++++-------- docker-compose.yml | 10 ++-------- frontend/nginx.conf | 27 +++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 9f3ce7b..d5c161b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ Thumbs.db # Project storage (user uploaded files) storage/ +backup/ # Documentation files (可能是临时的) *.md.backup diff --git a/backend/Dockerfile b/backend/Dockerfile index a64ee6f..2e5b295 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -9,6 +9,7 @@ ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_NO_CACHE_DIR=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ + DEBIAN_FRONTEND=noninteractive \ PIP_DEFAULT_TIMEOUT=120 # 优先尝试阿里云 Debian 镜像源,失败时自动回退官方源 @@ -16,36 +17,34 @@ RUN set -eux; \ cp /etc/apt/sources.list.d/debian.sources /tmp/debian.sources.bak; \ sed -i 's|http://deb.debian.org|http://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources; \ sed -i 's|http://security.debian.org|http://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources; \ + dpkg --configure -a || true; \ + apt-get -f install -y || true; \ if ! apt-get update; then \ cp /tmp/debian.sources.bak /etc/apt/sources.list.d/debian.sources; \ + dpkg --configure -a || true; \ + apt-get -f install -y || true; \ apt-get update; \ fi; \ if ! apt-get install -y --no-install-recommends \ - build-essential \ - default-libmysqlclient-dev \ - pkg-config \ libpango-1.0-0 \ libpangoft2-1.0-0 \ libpangocairo-1.0-0 \ libgdk-pixbuf-2.0-0 \ libcairo2 \ - libffi-dev \ shared-mime-info \ fontconfig \ fonts-dejavu-core \ fonts-wqy-microhei; then \ cp /tmp/debian.sources.bak /etc/apt/sources.list.d/debian.sources; \ + dpkg --configure -a || true; \ + apt-get -f install -y || true; \ apt-get update; \ apt-get install -y --no-install-recommends \ - build-essential \ - default-libmysqlclient-dev \ - pkg-config \ libpango-1.0-0 \ libpangoft2-1.0-0 \ libpangocairo-1.0-0 \ libgdk-pixbuf-2.0-0 \ libcairo2 \ - libffi-dev \ shared-mime-info \ fontconfig \ fonts-dejavu-core \ diff --git a/docker-compose.yml b/docker-compose.yml index 6881212..04a45e6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ services: MYSQL_PASSWORD: ${DB_PASSWORD:-password_change_me} TZ: Asia/Shanghai volumes: - - mysql_data:/var/lib/mysql + - ${STORAGE_PATH:-./storage}/mysql:/var/lib/mysql - ./backend/scripts/init.sql:/docker-entrypoint-initdb.d/init.sql:ro ports: - "${MYSQL_PORT:-3306}:3306" @@ -35,7 +35,7 @@ services: environment: TZ: Asia/Shanghai volumes: - - redis_data:/data + - ${STORAGE_PATH:-./storage}/redis:/data ports: - "${REDIS_PORT:-6379}:6379" healthcheck: @@ -105,12 +105,6 @@ services: timeout: 10s retries: 3 -volumes: - mysql_data: - driver: local - redis_data: - driver: local - networks: default: name: nex-docus-network diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 41ca7d2..4a741bb 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -41,6 +41,33 @@ server { add_header Cache-Control "no-cache, no-store, must-revalidate"; } + # MCP Streamable HTTP 反向代理 + location = /mcp { + return 301 /mcp/; + } + + location /mcp/ { + proxy_pass http://backend:8000/mcp/; + 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_http_version 1.1; + proxy_set_header Connection ""; + + # MCP 可能返回流式响应,不能被 nginx 缓冲 + proxy_buffering off; + proxy_request_buffering off; + + # MCP 会话可能比普通 API 更长 + proxy_connect_timeout 60s; + proxy_send_timeout 3600s; + proxy_read_timeout 3600s; + + add_header Cache-Control "no-cache, no-store, must-revalidate"; + } + # PDF.js worker 文件 - 必须返回正确的 MIME type location /pdf-worker/ { types {