apisix/ssl_manager/DASHBOARD_TROUBLESHOOT.md

232 lines
6.2 KiB
Markdown
Raw 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.

# Dashboard 看不到路由和证书的排查指南
## 问题现象
测试脚本成功创建了路由和证书,但在 Dashboard 面板中看不到。
## 验证数据确实存在
### 通过 Admin API 验证
```bash
# 检查路由
curl -s http://localhost:9180/apisix/admin/routes/test.jingrowtools.cn \
-H 'X-API-KEY: 8206e6e42b6b53243c52a767cc633137'
# 检查 SSL
curl -s http://localhost:9180/apisix/admin/ssls/00000000000000000023 \
-H 'X-API-KEY: 8206e6e42b6b53243c52a767cc633137'
```
### 通过 etcd 验证
```bash
# 检查路由
docker exec apisix-etcd-1 etcdctl get /apisix/routes/test.jingrowtools.cn
# 检查 SSL
docker exec apisix-etcd-1 etcdctl get /apisix/ssls/00000000000000000023
```
## 可能的原因和解决方案
### 1. Dashboard 缓存问题 ⚠️ **最常见**
**原因:** Dashboard 可能缓存了数据,没有实时刷新。
**解决方案:**
- **刷新浏览器页面**F5 或 Ctrl+R
- **清除浏览器缓存**Ctrl+Shift+Delete
- **硬刷新**Ctrl+Shift+R 或 Ctrl+F5
- **等待几秒钟**后再次查看Dashboard 可能有轮询间隔)
### 2. Dashboard 过滤条件
**原因:** Dashboard 可能设置了过滤条件,隐藏了某些路由。
**解决方案:**
- 检查 Dashboard 的搜索/过滤框,确保没有输入过滤条件
- 检查路由列表的显示选项(如:显示所有、只显示启用的等)
- 尝试搜索 `test.jingrowtools.cn` 看是否能找到
### 3. Dashboard 连接问题
**原因:** Dashboard 可能连接到了不同的 etcd 实例。
**检查方法:**
```bash
# 检查 Dashboard 日志
docker logs apisix-dashboard --tail 50 | grep -i etcd
# 检查 Dashboard 配置
cat /home/jingrow/apisix/dashboard_conf/conf.yaml
```
**解决方案:**
- 确保 Dashboard 配置的 etcd 地址正确
- 重启 Dashboard`docker restart apisix-dashboard`
### 4. 路由/证书状态问题
**原因:** Dashboard 可能只显示特定状态的路由/证书。
**检查方法:**
```bash
# 检查路由状态
curl -s http://localhost:9180/apisix/admin/routes/test.jingrowtools.cn \
-H 'X-API-KEY: 8206e6e42b6b53243c52a767cc633137' | \
python3 -c "import sys, json; print(json.load(sys.stdin)['value']['status'])"
# 检查 SSL 状态
curl -s http://localhost:9180/apisix/admin/ssls/00000000000000000023 \
-H 'X-API-KEY: 8206e6e42b6b53243c52a767cc633137' | \
python3 -c "import sys, json; print(json.load(sys.stdin)['value']['status'])"
```
**解决方案:**
- 确保 `status: 1`(启用状态)
- 如果状态为 0需要启用
### 5. Dashboard 版本兼容性问题
**原因:** Dashboard 版本可能与 APISIX 版本不兼容。
**检查方法:**
```bash
# 检查 Dashboard 版本
docker exec apisix-dashboard cat /usr/local/apisix-dashboard/version 2>/dev/null || \
docker exec apisix-dashboard ls /usr/local/apisix-dashboard/
# 检查 APISIX 版本
docker exec apisix-apisix-1 apisix version
```
### 6. 权限问题
**原因:** Dashboard 用户可能没有查看权限。
**解决方案:**
- 检查 Dashboard 登录用户权限
- 尝试使用管理员账户登录
## 快速排查步骤
### 步骤 1: 验证数据存在
```bash
# 检查路由是否存在
curl -s http://localhost:9180/apisix/admin/routes \
-H 'X-API-KEY: 8206e6e42b6b53243c52a767cc633137' | \
python3 -c "import sys, json; routes=json.load(sys.stdin)['list']; \
test=[r for r in routes if 'test.jingrowtools.cn' in str(r.get('value', {}).get('name', ''))]; \
print(f'找到测试路由: {len(test)} 个')"
# 检查 SSL 是否存在
curl -s http://localhost:9180/apisix/admin/ssls \
-H 'X-API-KEY: 8206e6e42b6b53243c52a767cc633137' | \
python3 -c "import sys, json; ssls=json.load(sys.stdin)['list']; \
test=[s for s in ssls if 'test.jingrowtools.cn' in str(s.get('value', {}).get('snis', []))]; \
print(f'找到测试 SSL: {len(test)} 个')"
```
### 步骤 2: 刷新 Dashboard
1. 在浏览器中按 `Ctrl+Shift+R` 硬刷新
2. 等待 5-10 秒
3. 再次查看路由和 SSL 列表
### 步骤 3: 检查 Dashboard 连接
```bash
# 重启 Dashboard
docker restart apisix-dashboard
# 等待启动
sleep 5
# 检查日志
docker logs apisix-dashboard --tail 20
```
### 步骤 4: 直接通过 Dashboard API 查询
```bash
# 访问 Dashboard API需要登录 token
# 在浏览器中打开开发者工具F12查看 Network 请求
# 找到 Dashboard API 的请求,查看返回的数据
```
## 常见解决方案
### 方案 1: 强制刷新(最简单)
1. 打开 Dashboard
2.`Ctrl+Shift+R` 硬刷新
3. 等待几秒钟
4. 再次查看
### 方案 2: 重启 Dashboard
```bash
docker restart apisix-dashboard
```
等待 10 秒后刷新浏览器。
### 方案 3: 检查路由状态
如果路由状态为 0禁用需要启用
```bash
# 启用路由
curl -X PUT http://localhost:9180/apisix/admin/routes/test.jingrowtools.cn \
-H 'X-API-KEY: 8206e6e42b6b53243c52a767cc633137' \
-H 'Content-Type: application/json' \
-d '{
"uri": "/*",
"name": "test.jingrowtools.cn",
"host": "test.jingrowtools.cn",
"status": 1,
...
}'
```
## 验证脚本
创建一个验证脚本检查 Dashboard 是否能访问数据:
```bash
#!/bin/bash
# 验证 Dashboard 数据访问
echo "检查路由..."
curl -s http://localhost:9180/apisix/admin/routes \
-H 'X-API-KEY: 8206e6e42b6b53243c52a767cc633137' | \
python3 -c "import sys, json; data=json.load(sys.stdin); \
print(f'总路由数: {len(data[\"list\"])}'); \
test=[r for r in data['list'] if 'test' in str(r.get('value', {}).get('name', ''))]; \
print(f'测试路由数: {len(test)}')"
echo ""
echo "检查 SSL..."
curl -s http://localhost:9180/apisix/admin/ssls \
-H 'X-API-KEY: 8206e6e42b6b53243c52a767cc633137' | \
python3 -c "import sys, json; data=json.load(sys.stdin); \
print(f'总 SSL 数: {len(data[\"list\"])}'); \
test=[s for s in data['list'] if 'test' in str(s.get('value', {}).get('snis', []))]; \
print(f'测试 SSL 数: {len(test)}')"
```
## 总结
**最可能的原因:**
1. ✅ Dashboard 缓存 - 需要刷新浏览器
2. ✅ Dashboard 过滤条件 - 检查搜索框
3. ✅ 数据状态 - 确保 status=1
**快速解决:**
1. 硬刷新浏览器Ctrl+Shift+R
2. 等待 5-10 秒
3. 检查搜索/过滤条件
4. 如果还不行,重启 Dashboard