Cloudflare Tunnel 配置说明
因最近有deepseek免费API,所以使用Cloudflare Tunnel + docker(openwebui)实现内网穿透,这样访问网址就行,这里只有Cloudflare Tunnel 配置
1. 准备工作
- 域名:dudu.cn(这里是假的示例
- 软件:cloudflared
- 端口:8080(OpenWebUI)
2. 安装步骤
使用 winget 安装 cloudflared
winget install cloudflare.cloudflared
3. 配置步骤
1. 登录(需要在浏览器中授权)
cloudflared login
登陆后授权
2. 创建新的 tunnel
cloudflared tunnel create openwebui-tunnel
openwebui-tunnel是你自己决定的名称
3. 配置文件位置
C:\Users\用户名称.cloudflared\config.yml
4. 配置文件内容
tunnel: <您的Tunnel-ID>
credentials-file: C:\Users\用户名称\.cloudflared\<您的Tunnel-ID>.json
ingress:
- hostname: 任意.dudu.cn
service: http://localhost:8080
- service: http_status:404
5. 配置 DNS
cloudflared tunnel route dns openwebui-tunnel 任意.dudu.cn
4. 服务安装
以管理员身份运行 PowerShell,然后:
cloudflared service install cloudflared service start
5. 验证方式
- 访问 https://任意.dudu.cn
- 检查服务状态:cloudflared tunnel info openwebui-tunnel
6. 常用命令
查看所有 tunnel
cloudflared tunnel list
查看 tunnel 状态
cloudflared tunnel info openwebui-tunnel
服务操作
cloudflared service start cloudflared service stop cloudflared service restart
7. 故障排除
-
如果服务启动失败
- 检查配置文件路径
- 确保以管理员权限运行
- 查看 Windows 服务
-
如果无法访问
- 确认 OpenWebUI 是否运行在 8080 端口
- 检查 Cloudflare DNS 设置
- 验证 tunnel 状态
-
重要文件位置
- 配置文件:C:\Users\用户名称.cloudflared\config.yml
- 证书文件:C:\Users\用户名称.cloudflared\cert.pem
- 凭据文件:C:\Users\用户名称.cloudflared<Tunnel-ID>.json
注意事项:
- 所有命令最好在管理员权限下运行
- 保存好 Tunnel ID 和配置文件
- 确保 OpenWebUI 在配置 tunnel 前已经运行
- 定期检查服务状态