Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions document/content/self-host/upgrading/4-15/4150.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,32 @@ description: 'FastGPT V4.15.0 更新说明'

`fastgpt-app`, `fastgpt-pro` 可增加文件解析并发线程数

```bash
# 文件解析 worker 并发数
```dotenv
# 文件解析 worker 并发数(可选)
PARSE_FILE_WORKERS=10
# 文件解析超时时间(秒)
# 文件解析超时时间(秒)(可选)
PARSE_FILE_TIMEOUT_SECONDS=600
# HTML 转 Markdown worker 并发数
# HTML 转 Markdown worker 并发数(可选)
HTML_TO_MARKDOWN_WORKERS=10
# 文本切块 worker 并发数
# 文本切块 worker 并发数(可选)
TEXT_TO_CHUNKS_WORKERS=10
# 自动同步 mongo 数据库索引, 改成 boolean 字符串值,而不是 0 和 1
# 自动同步 mongo 数据库索引, 改成 boolean 字符串值,而不是 0 和 1(可选)
SYNC_INDEX=true
# 是否启用可信反向代理客户端 IP 校验(可选)
TRUSTED_PROXY_ENABLE=false
# 可信反向代理 IP/CIDR 列表,逗号或空白分隔。仅 TRUSTED_PROXY_ENABLE=true 时生效;仅显式可信代理传入的 X-Forwarded-For/X-Real-IP 会用于客户端 IP 解析(可选)
TRUSTED_PROXY_IPS=
```

### 确认是否遗漏环境变量

本次升级,增加了对于环境变量的检测,避免漏填必须的环境变量,需重点检查`fastgpt-app`和`fastgpt-pro`是否包含:

```dotenv
# 密钥加密密钥,两个服务需一致
AES256_SECRET_KEY=
# 文件 token 密钥,两个服务需一致
FILE_TOKEN_KEY=
```

## 🚀 新增内容
Expand All @@ -45,6 +60,7 @@ SYNC_INDEX=true
5. 加强第三方知识库请求的 SSRF 防护。
6. codex-sandbox 加强 AST 检查,防止绕过安全检查。
7. 站点同步限流错误提示,重复提示。
8. 加强 IP 检测,避免伪造绕过。

## 🐛 修复

Expand Down
10 changes: 5 additions & 5 deletions document/data/doc-last-modified.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@
"content/openapi/intro.mdx": "2026-04-26T21:08:47+08:00",
"content/openapi/share.en.mdx": "2026-04-26T21:08:47+08:00",
"content/openapi/share.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/config/env.en.mdx": "2026-04-30T00:20:04+08:00",
"content/self-host/config/env.mdx": "2026-04-30T00:20:04+08:00",
"content/self-host/config/env.en.mdx": "2026-05-06T18:25:24+08:00",
"content/self-host/config/env.mdx": "2026-05-06T18:25:24+08:00",
"content/self-host/config/json.en.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/config/json.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/config/model/intro.en.mdx": "2026-04-26T21:08:47+08:00",
Expand Down Expand Up @@ -257,7 +257,7 @@
"content/self-host/upgrading/4-14/41481.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/4-14/4149.en.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/4-14/4149.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/4-15/4150.mdx": "2026-05-06T14:03:59+08:00",
"content/self-host/upgrading/4-15/4150.mdx": "2026-05-06T18:31:58+08:00",
"content/self-host/upgrading/outdated/40.en.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/outdated/40.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/outdated/41.en.mdx": "2026-04-26T21:08:47+08:00",
Expand Down Expand Up @@ -398,8 +398,8 @@
"content/self-host/upgrading/outdated/499.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/upgrade-intruction.en.mdx": "2026-04-26T21:08:47+08:00",
"content/self-host/upgrading/upgrade-intruction.mdx": "2026-04-26T21:08:47+08:00",
"content/toc.en.mdx": "2026-04-29T23:22:43+08:00",
"content/toc.mdx": "2026-04-29T23:22:43+08:00",
"content/toc.en.mdx": "2026-05-06T18:25:24+08:00",
"content/toc.mdx": "2026-05-06T18:25:24+08:00",
"content/use-cases/app-cases/dalle3.en.mdx": "2026-04-26T21:08:47+08:00",
"content/use-cases/app-cases/dalle3.mdx": "2026-04-26T21:08:47+08:00",
"content/use-cases/app-cases/english_essay_correction_bot.en.mdx": "2026-04-26T21:08:47+08:00",
Expand Down
2 changes: 1 addition & 1 deletion packages/global/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@apidevtools/swagger-parser": "^10.1.0",
"@bany/curl-to-json": "^1.2.8",
"axios": "catalog:",
"ipaddr.js": "catalog:",
"cron-parser": "^4.9.0",
"dayjs": "catalog:",
"encoding": "^0.1.13",
Expand All @@ -24,7 +25,6 @@
"next": "catalog:",
"openai": "6.34.0",
"openapi-types": "^12.1.3",
"ipaddr.js": "^2.3.0",
"timezones-list": "^3.0.2",
"lodash": "catalog:",
"zod": "catalog:",
Expand Down
4 changes: 2 additions & 2 deletions packages/service/common/geo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import type { LocationName } from './type';
import { extractLocationData } from './utils';
import type { NextApiRequest } from 'next';
export type { NextApiRequest } from 'next';
import { getClientIp } from 'request-ip';
import { getLogger } from '../logger';
import type { localeType } from '@fastgpt/global/common/i18n/type';
import { formatI18nLocationToZhEn } from '@fastgpt/global/common/i18n/utils';
import { getClientIpFromRequest } from '../security/clientIp';

const logger = getLogger(['GEO']);

Expand Down Expand Up @@ -109,7 +109,7 @@ export function initGeo() {
}

export function getIpFromRequest(request: NextApiRequest): string {
const ip = getClientIp(request);
const ip = getClientIpFromRequest(request);
if (!ip || ip === '::1') {
return '127.0.0.1';
}
Expand Down
3 changes: 2 additions & 1 deletion packages/service/common/middle/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getLogger, LogCategories, withContext } from '../logger';
import { setSpanError, withActiveSpan } from '../tracing';
import { ZodError } from 'zod';
import { randomUUID } from 'crypto';
import { getClientIpFromRequest } from '../security/clientIp';

export type NextApiHandler<T = any> = (
req: ApiRequestProps,
Expand Down Expand Up @@ -61,7 +62,7 @@ export const NextEntry = ({
const url = req.url || '';
const route = getRequestRoute(url);
const method = req.method?.toUpperCase() || '';
const ip = req.headers['x-forwarded-for'] || req.socket?.remoteAddress;
const ip = getClientIpFromRequest(req);
const userAgent = req.headers['user-agent'];
const contentLength = req.headers['content-length'];
const requestBodySize = parseHeaderNumber(contentLength);
Expand Down
7 changes: 4 additions & 3 deletions packages/service/common/middle/reqFrequencyLimit.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { type ApiRequestProps } from '../../type/next';
import requestIp from 'request-ip';
import { authFrequencyLimit } from '../system/frequencyLimit/utils';
import { addSeconds } from 'date-fns';
import { type NextApiResponse } from 'next';
import { jsonRes } from '../response';
import { serviceEnv } from '../../env';
import { getClientIpFromRequest } from '../security/clientIp';

// unit: times/s
// how to use?
Expand All @@ -21,10 +21,11 @@ export function useIPFrequencyLimit({
force?: boolean;
}) {
return async (req: ApiRequestProps, res: NextApiResponse) => {
const ip = requestIp.getClientIp(req);
if (!ip || (!serviceEnv.USE_IP_LIMIT && !force)) {
if (!serviceEnv.USE_IP_LIMIT && !force) {
return;
}

const ip = getClientIpFromRequest(req) ?? 'unknown';
try {
await authFrequencyLimit({
eventId: `ip-qps-limit-${id}-` + ip,
Expand Down
Loading
Loading