document/content/self-host/config/sandbox/sealosdevbox.mdx
import { Alert } from '@/components/docs/Alert';
<Alert icon="⚠️" context="warning"> 仅商业版用户支持,可联系客服申请密钥,计费方式为按量计费,扣除 sealos 余额。 </Alert>fastgpt-agent-sandbox-proxy 服务。在 fastgpt-app 和 fastgpt-pro 中增加下面环境变量。
# 启用 Sealos Devbox 作为 Agent Sandbox provider
AGENT_SANDBOX_PROVIDER=sealosdevbox
# 客服提供的 Sealos Devbox Server API 地址,FastGPT 主服务需要能访问
AGENT_SANDBOX_SEALOS_BASEURL=https://devbox-server.example.com
# 客服提供的访问密钥
AGENT_SANDBOX_SEALOS_TOKEN=replace_with_sealos_devbox_token
# 沙盒镜像版本
AGENT_SANDBOX_SEALOS_IMAGE=hub.hzh.sealos.run/labring/devbox-sandbox:v0.2.0
# Devbox 单实例资源上限;存储容量单位为 GB
AGENT_SANDBOX_CPU_COUNT=1
AGENT_SANDBOX_MEMORY_MIB=2048
AGENT_SANDBOX_STORAGE_SIZE_GI=1
OpenSandbox 和 Sealos Devbox 共用同一套依赖源配置;其中 apt 镜像仅对 root 权限的 Agent 沙箱有效:
AGENT_SANDBOX_NPM_REGISTRY=https://registry.npmmirror.com
AGENT_SANDBOX_PYPI_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
AGENT_SANDBOX_APT_MIRROR=https://mirrors.tuna.tsinghua.edu.cn/debian
对于 root 权限的 Agent 沙箱,FastGPT 会根据发行版生成并覆盖标准的 Ubuntu 或 Debian .sources 文件,并在覆盖已有文件前创建 .copy 备份。删除该环境变量后,有 .copy 备份的文件会恢复,没有备份的文件会跳过。初始化阶段不会执行 apt-get update。arm64 运行镜像应配置提供对应架构软件包的镜像地址。
启用 AGENT_SANDBOX_PROVIDER=sealosdevbox 后,fastgpt-app 必须配置 AGENT_SANDBOX_PROXY_SECRET、AGENT_SANDBOX_PROXY_URL 和 AGENT_SANDBOX_PREVIEW_PROXY_URL,fastgpt-pro 必须配置 AGENT_SANDBOX_PREVIEW_PROXY_URL。Proxy Secret 需与 fastgpt-agent-sandbox-proxy 服务中的值一致,且不少于 32 位。
sealosdevbox provider 启用后必须配置 AGENT_SANDBOX_SEALOS_IMAGE。请使用客服提供或与当前 FastGPT 版本匹配的 Agent Sandbox 运行态镜像。
检查代理服务是否能被浏览器访问,并确认反向代理已支持 WebSocket Upgrade。如果 FastGPT 通过 HTTPS 访问,AGENT_SANDBOX_PROXY_URL 也应使用 wss://,避免浏览器拦截混合内容。
确认 FastGPT 主服务和 fastgpt-agent-sandbox-proxy 中的 AGENT_SANDBOX_PROXY_SECRET 完全一致,并且长度不少于 32 位。