最近我购买了个人域名,一直在思考怎么去搭建个人开发平台,包括OpenClaw智能体平台、个人博客和品牌网站,还需要部署一些自己写的管理子系统。
最简单方式肯定是直接去购买云主机,当前已经买了腾讯云的轻量级应用服务器,但是网络特别卡。要是购买云服务器CVM费用又太高了。
然后我突然想起来我家里还有2台Raspberry还闲置着呢?是不是可以发挥下它的作用。
然后我通过跟DeepSeek交流方案,它给出了一个当前最优的方案:
- 主域名指向我的个人静态网站并托管在Cloudflare Pages上,可保证全球访问的稳定性。
- 一台Raspberry用于部署管理子系统,包含前后端服务。通过Cloudflare Tunnel内网穿透,将域名绑定到我内网Nginx上。
在内网Nginx使用反向代理方式,所有/api请求转发到后端服务,其他请求转发到前端服务,内外服务全部使用HTTP即可。
- 一台Raspberry用于安装OpenClaw智能体平台。并通过长连接方式连接飞书平台,避免开放公网IP。
整体架构图如下:

Cloudflare Pages托管静态网站
我当前使用的是Hugo构建的个人静态网站,源代码托管在GitHub上面。
进入Cloudflare控制台后,在构建 > 计算 > Workers & Pages,点击 “创建应用程序” ➔ “Pages” ➔ “连接到 Git”。
授权访问GitHub仓库,个人私仓也是可以的。填写以下几个参数:
- 框架预设: 在下拉菜单中选择 Hugo
- 构建命令: 本地构建命令保持一致
- 输出目录: 填写 public(即 Hugo 默认的编译输出目录)
- 环境变量:HUGO_VERSION=你本地构建的Hugo版本号
然后点击构建和部署,成功消息
1
2
| 成功!您的项目已部署到以下区域:全球
您可以在 xiongneng-me.pages.dev 预览项目
|
这时候再选择添加自定义域名,输入xiongneng.me后保存,然后回去后再选择添加自定义域名,输入www.xiongneng.me后保存。
然后再去域名注册地方比如我的阿里云,在域名解析地方添加两条CNAME记录,一个是@,一个是www,都指向xiongneng-me.pages.dev
这样设置完成后,每次push到github上面会自动触发Cloudflare Pages的构建流程,整个过程十秒左右。
Cloudflare Tunnel内网穿透
先清空域名解析记录
我之前购买了腾讯云主机,并将域名解析配置到云主机IP。在阿里云上面购买的域名,
因此需要登录阿里云去域名解析那里把我的域名解析记录删掉即可。
准备:将域名托管给 Cloudflare
要让Cloudflare管理你的域名,你需要修改它的DNS服务器,这是后续一切的基础。
注册 Cloudflare 账号,并添加你的域名。输入你的完整域名(不要带 www),计划选择 Free 免费套餐。
Cloudflare 会提供两个新的 NS (Name Server) 地址,你需要复制下来。以 .ns.cloudflare.com 结尾。
再去阿里云域名控制台,找到你的域名,将它的 DNS 服务器修改为 Cloudflare 提供的那两个 NS 地址。
具体方法是找到 域名与网站 > 域名管理 > 域名列表。在列表中找到你的域名 > 管理 > DNS管理 > DNS修改。
然后点击修改DNS服务器,在弹出的窗口中,删除原来阿里云的 NS 地址,然后再把上面的两个NS地址复制进去。
等待DNS生效(一般几分钟到几小时),期间网站服务可能会短暂中断。生效后,域名就算正式托管给 Cloudflare 了。
安装Nginx
在树莓派上安装Nginx
1
| sudo apt install nginx -y
|
新增个人域名网站配置/etc/nginx/conf.d/xiongneng.conf,内容如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| server {
listen 80;
server_name xiongneng.me www.xiongneng.me;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
|
创建隧道:打通内外网
后面两步需要在树莓派的终端里完成,我们一条条来。
🔑 步骤一:安装 cloudflared
1
2
3
4
5
| # 下载并安装 cloudflared (适用于 Ubuntu 24.04)
wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64.deb
sudo dpkg -i cloudflared-linux-arm64.deb
# 验证安装是否成功
cloudflared --version
|
🔑 步骤二:认证并创建隧道
1
2
| # 用你的 Cloudflare 账号授权这台树莓派
cloudflared tunnel login
|
这条命令执行后,会给你返回一个浏览器页面地址。将它复制出来,打开浏览器,让你选择域名并授权。它会自动生成TLS证书,耐心等待几秒。
认证成功后,开始创建隧道:
1
2
| # 创建一个新隧道,名字可以自己取
cloudflared tunnel create xiong-tunnel
|
成功后,会生成一个唯一的 Tunnel ID 和对应的 credentials 文件,同时会告诉你如何通过 DNS 路由流量。
🚀 步骤三:配置 DNS
1
2
3
| # 创建一条 DNS CNAME 记录,将你的域名(两个域名,包含www)指向这个隧道
cloudflared tunnel route dns xiongneng-tunnel xiongneng.me
cloudflared tunnel route dns xiongneng-tunnel www.xiongneng.me
|
如果以上都没有报错,并且提示连接成功,就说明你的隧道已经跑通了。
服务一旦启用,Cloudflare 会自动为你的域名签发并续期 SSL/TLS 证书,访客看到的将是受信任的安全连接
让隧道常驻后台
在系统服务专用的目录下创建 config.yml
1
| sudo mkdir -p /etc/cloudflared
|
编辑配置文件sudo vim /etc/cloudflared/config.yml,内容如下。
1
2
3
4
5
6
7
8
9
10
11
12
| tunnel: xiongneng-tunnel
credentials-file: /home/ubuntu/.cloudflared/你的隧道ID.json
ingress:
- hostname: xiongneng.me
service: http://localhost:80
- hostname: www.xiongneng.me
service: http://localhost:80
# 如果你还有想公开的子域名,可以继续添加规则
# - hostname: admin.xiongneng.me
# service: http://localhost:8080
- service: http_status:404
|
验证配置文件正确性:
1
| sudo cloudflared tunnel --config /etc/cloudflared/config.yml ingress validate
|
创建并启用 Systemd 服务
1
| sudo vim /etc/systemd/system/cloudflared.service
|
粘贴以下内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
| [Unit]
Description=Cloudflare Tunnel Service
After=network.target
[Service]
TimeoutStartSec=0
Type=notify
ExecStart=/usr/bin/cloudflared --config /etc/cloudflared/config.yml tunnel run
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
|
这个文件告诉 systemd 如何管理和启动 cloudflared 服务。
启动并验证服务:
1
2
3
4
5
6
7
8
| # 重新加载 systemd 配置
sudo systemctl daemon-reload
# 设置服务开机自启
sudo systemctl enable cloudflared
# 立即启动服务
sudo systemctl start cloudflared
# 检查服务运行状态
sudo systemctl status cloudflared
|
安装Hermes
默认会去连外网下载导致特别慢。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| # 删除旧安装目录
rm -rf ~/.hermes ~/.local/bin/uv ~/.config/uv
# 安装系统前置依赖
sudo apt update && sudo apt install -y git curl python3 python3-pip ripgrep ffmpeg
# 配置国内pip源加速
pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip3 config set global.trusted-host mirrors.aliyun.com
# git github加速
git config --global url."https://mirror.ghproxy.com/https://github.com".insteadOf "https://github.com"
# pip安装到用户目录
pip3 install uv==0.11.29 --user
# 复制到Hermes目录(关键)
mkdir -p ~/.hermes/bin
cp ~/.local/bin/uv ~/.hermes/bin/
export PATH="$HOME/.hermes/bin:$PATH"
# 验证uv是否正常
uv --version
# 给 uv 配置国内 Python 镜像
cat >> ~/.bashrc <<EOF
export UV_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/
export UV_PYTHON_INSTALL_MIRROR=https://mirrors.ustc.edu.cn/github-release/astral-sh/python-build-standalone/
export UV_PYTHON_DOWNLOAD=1
EOF
source ~/.bashrc
# 下载国内镜像安装脚本
curl -fsSL https://res1.hermesagent.org.cn/install.sh -o hermes-install.sh
# 运行脚步
bash hermes-install.sh
|
剩余的步骤参考文章 [[Ubuntu24安装Hermes Agent]]