把 OpenClaw 部署到企业环境,需要考虑的不只是「能跑起来」, 更要解决:谁能用、能做什么、数据不外泄、出问题能追溯。
多用户架构选型
方案 A:每人独立 Gateway(推荐,强隔离)
员工 A ──── Gateway A(独立进程)──── Claude API
员工 B ──── Gateway B(独立进程)──── Claude API
员工 C ──── Gateway C(独立进程)──── Claude API
优点:
- 完全隔离,互不影响
- 每人独立配置(不同模型/工具/权限)
- 一个人的问题不影响其他人
缺点:
- 资源占用多(N 个进程)
- 管理成本高
适合:高安全要求、每人需要独立配置的企业。
方案 B:共享 Gateway + 多 Agent(省资源)
单一 Gateway
├── Agent-Alice(Telegram: alice_bot,只能用工作工具)
├── Agent-Bob(Telegram: bob_bot,开发工具全权限)
└── Agent-Public(Slack: #ai-assistant,只读权限)
优点:
- 一个进程服务所有人
- 集中管理配置和日志
缺点:
- 共享状态,需要更严格的权限设计
适合:50 人以下团队,需要集中运维。
白名单访问控制
json
{
"channels": {
"telegram": {
"botToken": "TEAM_BOT_TOKEN",
"allowedUsers": [
123456789,
987654321,
111222333
]
},
"slack": {
"enabled": true,
"allowedChannels": ["#engineering", "#ai-requests"],
"allowedUsers": ["U12345", "U67890"]
}
}
}基于角色的权限层次:
json
{
"agents": {
"default": {
"permissions": {
"allow": ["Read", "Bash(git *)", "Bash(npm test)"],
"deny": ["Bash(rm *)", "Bash(sudo *)", "Write(/etc/*)"]
}
},
"admins": {
"allowedUsers": [123456789],
"permissions": {
"allow": ["Read", "Write", "Bash(*)"]
}
}
}
}沙箱安全隔离
企业环境下,AI 执行命令必须在沙箱中:
json
{
"agents": {
"defaults": {
"sandbox": {
"type": "docker",
"docker": {
"image": "node:20-slim",
"setupCommand": "apt-get install -y git curl",
"network": "none",
"readonlyRootfs": false,
"resources": {
"memory": "512m",
"cpus": "1.0"
},
"mounts": [
{
"host": "/home/user/projects",
"container": "/workspace",
"readonly": false
}
]
}
}
}
}
}沙箱保障:
network: none— AI 无法访问互联网(完全内网)readonlyRootfs— 防止修改系统文件mounts— 只挂载必要目录,最小权限原则
完全内网环境:接入 Ollama 本地模型
不想让对话数据出公司?在内网部署 Ollama:
bash
# 1. 在内网服务器安装 Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# 2. 下载模型(选一个适合企业的)
ollama pull qwen2.5-coder:32b # 代码能力强
ollama pull llama3.3:70b # 综合能力强
# 3. 启动 Ollama API 服务(监听内网 IP)
OLLAMA_HOST=0.0.0.0:11434 ollama serve
# 4. 配置 OpenClaw 使用 Ollamajson
{
"providers": [
{
"name": "ollama-internal",
"type": "openai-compatible",
"baseUrl": "http://192.168.1.100:11434/v1",
"apiKey": "ollama",
"models": ["qwen2.5-coder:32b", "llama3.3:70b"]
}
],
"defaultProvider": "ollama-internal",
"defaultModel": "qwen2.5-coder:32b"
}完全内网验证:
bash
# 确认流量不出内网
sudo tcpdump -i eth0 host anthropic.com # 不应有流量审计日志
json
{
"logging": {
"level": "info",
"auditLog": {
"enabled": true,
"path": "/var/log/openclaw/audit.jsonl",
"includeMessages": true, // 记录对话内容(合规要求)
"includeTools": true // 记录工具调用
}
}
}审计日志格式(每行一个 JSON):
json
{"timestamp": "2026-03-21T10:00:00Z", "userId": "123456789", "channel": "telegram", "action": "message", "model": "claude-sonnet-4-6", "tokens": {"input": 234, "output": 567}}
{"timestamp": "2026-03-21T10:00:05Z", "userId": "123456789", "tool": "Bash", "command": "git log --oneline -10", "result": "ok"}高可用部署(大型团队)
负载均衡(Nginx)
├── Gateway 实例 1(主)
├── Gateway 实例 2(备)
└── 共享 Redis(会话状态)
配置 Redis 共享会话:
json
{
"session": {
"store": "redis",
"redis": {
"url": "redis://redis.internal:6379",
"prefix": "openclaw:sessions:"
}
}
}nginx
# Nginx 配置:WebSocket 负载均衡
upstream openclaw_gateway {
ip_hash; # 同一用户粘连到同一实例
server 10.0.0.1:18789;
server 10.0.0.2:18789;
}
server {
listen 443 ssl;
location / {
proxy_pass http://openclaw_gateway;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}合规检查清单
数据安全:
[ ] 所有对话数据留存在内网(用 Ollama 或私有 API 端点)
[ ] 审计日志已开启,保留 90 天
[ ] 沙箱隔离,AI 无法访问敏感系统目录
访问控制:
[ ] allowedUsers 白名单已配置
[ ] 权限最小化(Deny 列表包含 rm -rf / sudo)
[ ] 管理员账号有额外的操作日志
网络安全:
[ ] Gateway 不直接暴露到公网
[ ] 通过 VPN/Tailscale 或 HTTPS 代理访问
[ ] Gateway auth.token 已设置强密码
来源:OpenClaw 官方文档 - docs.openclaw.ai/gateway