[ PROMPT_NODE_24372 ]
Tunnel 配置说明
[ SKILL_DOCUMENTATION ]
# 隧道配置
## 配置源
隧道使用以下两种配置源之一:
| 配置源 | 存储位置 | 更新方式 | 用例 |
|---------------|---------|---------|----------|
| 本地 | `config.yml` 文件 | 编辑文件,重启 | 开发、多环境、版本控制 |
| Cloudflare | 控制面板/API | 即时生效,无需重启 | 生产环境、集中式管理 |
**基于 Token 的隧道** = 配置源:Cloudflare
**本地管理的隧道** = 配置源:本地
## 配置文件位置
~/.cloudflared/config.yml # 用户配置
/etc/cloudflared/config.yml # 系统级配置 (Linux)
## 基本结构
yaml
tunnel:
credentials-file: /path/to/.json
ingress:
- hostname: app.example.com
service: http://localhost:8000
- service: http_status:404 # 必须包含的兜底规则
## 入口规则
规则从**上到下**评估,首个匹配项生效。
yaml
ingress:
# 精确主机名 + 路径正则
- hostname: static.example.com
path: .(jpg|png|css|js)$
service: https://localhost:8001
# 通配符主机名
- hostname: "*.example.com"
service: https://localhost:8002
# 仅路径(所有主机名)
- path: /api/.*
service: http://localhost:9000
# 兜底规则(必须)
- service: http_status:404
**验证**:
bash
cloudflared tunnel ingress validate
cloudflared tunnel ingress rule https://foo.example.com
## 服务类型
| 协议 | 格式 | 客户端要求 |
|----------|--------|-------------------|
| HTTP | `http://localhost:8000` | 浏览器 |
| HTTPS | `https://localhost:8443` | 浏览器 |
| TCP | `tcp://localhost:2222` | `cloudflared access tcp` |
| SSH | `ssh://localhost:22` | `cloudflared access ssh` |
| RDP | `rdp://localhost:3389` | `cloudflared access rdp` |
| Unix | `unix:/path/to/socket` | 浏览器 |
| Test | `hello_world` | 浏览器 |
## 源站配置
### 连接设置
yaml
originRequest:
connectTimeout: 30s
tlsTimeout: 10s
tcpKeepAlive: 30s
keepAliveTimeout: 90s
keepAliveConnections: 100
### TLS 设置
yaml
originRequest:
noTLSVerify: true # 禁用证书验证
originServerName: "app.internal" # 覆盖 SNI
caPool: /path/to/ca.pem # 自定义 CA
### HTTP 设置
yaml
originRequest:
disableChunkedEncoding: true
httpHostHeader: "app.internal"
http2Origin: true
## 私有网络模式
yaml
tunnel:
credentials-file: /path/to/creds.json
warp-routing:
enabled: