Files
2026-06-30 15:14:37 +08:00

209 lines
4.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# MeshRay Docker 部署指南
## 快速部署
### 1. 准备配置文件
复制示例配置文件并根据需要修改:
```bash
cp ../../configs/config.example.yaml ./config.yaml
```
### 2. 修改配置(可选)
编辑 `config.yaml` 文件,特别是 STUN/TURN 服务器配置:
```yaml
# STUN 服务器配置
stun:
# 默认 STUN 服务器列表(国内和国外)
default_servers:
# 国内 STUN 服务器
- stun:stun.qq.com:3478
- stun:stun.miwifi.com:3478
- stun:stun.bige0.com:3478
# 国外 STUN 服务器(Google
- stun:stun.l.google.com:19302
- stun:stun1.l.google.com:19302
- stun:stun2.l.google.com:19302
- stun:stun3.l.google.com:19302
- stun:stun4.l.google.com:19302
# 国外 STUN 服务器(其他)
- stun:stun.cloudflare.com:3478
- stun:stun.nextcloud.com:443
- stun:stun.sipgate.net:3478
- stun:stun.antisip.com:3478
- stun:stun.sonetel.com:3478
- stun:stun.voipgate.com:3478
# STUN 服务器选择策略
# auto: 自动选择(优先国内,延迟低的优先)
# domestic: 仅使用国内服务器
# international: 仅使用国外服务器
# custom: 仅使用自定义服务器
selection_strategy: auto
# 是否启用 STUN 服务器自动测试
auto_test: true
# STUN 测试间隔(秒)
test_interval: 300
# STUN 超时时间(秒)
timeout: 5
# TURN 服务器配置(可选)
turn:
# 默认 TURN 服务器
# 如果配置了 TURN 服务器,将作为 STUN 穿透失败时的回退方案
default_servers: []
# 示例配置:
# - url: turn:turn.example.com:3478
# username: user
# credential: pass
# auth_type: credential
```
### 3. 启动服务
```bash
# 创建必要目录
mkdir -p data logs
# 启动服务
docker-compose up -d
# 查看日志
docker-compose logs -f
```
### 4. 访问服务
打开浏览器访问:http://your-server-ip:9531
## 配置说明
### STUN 服务器配置
#### 国内 STUN 服务器(推荐)
- `stun:stun.qq.com:3478` - 腾讯 STUN 服务器
- `stun:stun.miwifi.com:3478` - 小米 STUN 服务器
- `stun:stun.bige0.com:3478` - 国内公共 STUN 服务器
#### 国外 STUN 服务器
- `stun:stun.l.google.com:19302` - Google STUN 服务器
- `stun:stun.cloudflare.com:3478` - Cloudflare STUN 服务器
- `stun:stun.nextcloud.com:443` - Nextcloud STUN 服务器
#### 选择策略
- `auto`: 自动选择(优先国内,延迟低的优先)
- `domestic`: 仅使用国内服务器(适合国内用户)
- `international`: 仅使用国外服务器(适合海外用户)
- `custom`: 仅使用自定义服务器
### TURN 服务器配置
TURN 服务器用于 STUN 穿透失败时的中继方案,支持以下鉴权方式:
- `credential`: 用户名密码(自建 coturn
- `token`: Token(商业服务如 Twilio、Xirsys
- `secret`: Shared Secret(信令签发)
## 常用命令
```bash
# 启动服务
docker-compose up -d
# 停止服务
docker-compose down
# 重启服务
docker-compose restart
# 查看日志
docker-compose logs -f
# 查看服务状态
docker-compose ps
# 更新镜像
docker-compose pull
docker-compose up -d
```
## 故障排查
### 1. 服务无法启动
```bash
# 查看日志
docker-compose logs
# 检查配置文件
cat config.yaml
```
### 2. STUN 穿透失败
```bash
# 检查 STUN 服务器配置
grep -A 20 "stun:" config.yaml
# 修改选择策略
# 将 selection_strategy 改为 domestic 或 international
```
### 3. 端口冲突
```bash
# 修改 docker-compose.yml 中的端口映射
ports:
- "9532:9531" # 改为其他端口
```
## 高级配置
### 使用 host 网络模式(推荐)
对于需要更好网络性能的场景,可以使用 host 网络模式:
1. 编辑 `docker-compose.yml`
2. 取消注释 `network_mode: host`
3. 注释掉 `ports` 配置
4. 重启服务
```yaml
services:
meshray:
# ...
network_mode: host
# ports:
# - "9531:9531"
```
### 自定义 STUN 服务器
如果需要使用自己的 STUN 服务器:
```yaml
stun:
default_servers:
- stun:your-stun-server.com:3478
selection_strategy: custom
```
### 配置 TURN 服务器
```yaml
turn:
default_servers:
- url: turn:your-turn-server.com:3478
username: your-username
credential: your-password
auth_type: credential
```
## 注意事项
1. **首次启动**:首次启动会自动生成管理员密码,请查看日志获取
2. **数据持久化**:配置文件、数据和日志都通过 volume 挂载,确保数据安全
3. **网络性能**:建议使用 host 网络模式以获得最佳性能
4. **STUN 选择**:国内用户建议使用 `domestic` 策略,海外用户建议使用 `international` 策略