
哪吒监控 Dashboard 之前使用的官方一键安装脚本,选择 standalone 方式部署的。
主控端更换服务器,想在 ServerStatus 主题上进行一些页面修改,服务器已经运行 docker 服务,不使用官方一键脚本,直接 docker 下部署 Dashboard。
域名解析
哪吒需要有两个公网端口,默认一个 8008 端口用于面板的访问 ,另一个 5555 端口用于客户端上报数据。
8008 端口绑定域名为 tz.196000.xyz,可打开小黄云开启 CDN 隐藏源站 IP。
5555 端口绑定域名为 tzrpc.196000.xyz,不能打开小黄云。
配置登录
- 登录 Github,点击右上角头像,选择 Settings, 点击 Developer settings,点击 New OAuth App
- 填写注册信息(以下内容可在提交后修改):
- Application name - 随意填写,如:
tz - Homepage URL - 填写面板的访问域名,如:
https://tz.196000.xyz - Authorization callback URL - 填写回调地址,如:
https://tz.196000.xyz/oauth2/callback - 点击 Register application
- 保存页面中的 Client ID,然后点击 “Generate a new client secret“,创建一个新的 Client Secret,新建的密钥仅会显示一次,请妥善保存
- Application name - 随意填写,如:
配置 yaml
完整 docker-compose.yml
version: '3'
services:
# nezha
nezha:
image: ghcr.io/naiba/nezha-dashboard:v0.18.2
container_name: nezha
restart: "always"
ports:
- 8008:80 # HTTPPort
- 5555:5555 # GRPCPort
volumes:
- /opt/docker/data/nezha/data:/dashboard/data
- /opt/docker/data/nezha/static-custom/static:/dashboard/resource/static/custom:ro
- /opt/docker/data/nezha/theme-custom/template:/dashboard/resource/template/theme-custom:ro
- /opt/docker/data/nezha/dashboard-custom/template:/dashboard/resource/template/dashboard-custom:ro
部署 Dashboard
下载主题文件
# 方主题开发仓库
git clone https://github.com/nezhahq/skeleton-custom-theme.git /opt/docker/data/nezha
# 安装目录
cd /opt/docker/data/nezha
# 删除无用到的文件
rm -rf .git .gitignore README.md docker-compose.yaml
# 同步官方 ServerStatus 主题最新文件
git clone https://github.com/naiba/nezha.git /opt/docker/data/nezha_temp
cp -rf /opt/docker/data/nezha_temp/resource/template/theme-server-status/* /opt/docker/data/nezha/theme-custom/template/
# 排除 header.html 文件,所有模板 html 文件内容 theme-server-status/ 替换为 theme-custom/
# 排除文件 header.html 因为导入了 css/js 等文件有路径问题,不替换,保留用原主题的文件,替换可见文末的路径按需替换路径即可
# find . -type f -exec sed -i 's/theme-server-status\//theme-custom\//g' {} \;
find . -type f ! -name 'header.html' -exec sed -i 's/theme-server-status\//theme-custom\//g' {} +
# 删除无用到的文件
rm -rf /opt/docker/data/nezha_temp
修改配置文件
修改以下几项
/opt/docker/data/nezha/data/config.yaml
GRPCHost: tzrpc.196000.xyz
GRPCPort: 5555
HTTPPort: 80
Oauth2:
Admin: xxxx
AdminGroups: ""
ClientID: xxxx
ClientSecret: xxxx
Type: github
Site:
Brand: tz
DashboardTheme: default
Theme: custom
完整目录结构
# root@y8gkz:~# tree /opt/docker/data/nezha
/opt/docker/data/nezha
├── dashboard-custom
│ └── template
├── data
│ ├── config.yaml
│ ├── config.yaml.bak
│ └── sqlite.db
├── static-custom
│ └── static #<---- 自定义静态文件路径
│ ├── css
│ │ └── 1111.css #<---- https://tz.196000.xyz/static-custom/css/1111.css
│ └── example.png
└── theme-custom
└── template #<---- 自定义主题模板文件路径,重启面板服务,登录后台,设置 --> 主题--> 选择Custom(local) 使用主题
├── content-footer.html
├── content-nav.html
├── footer.html
├── header.html
├── home-group-false.html
├── home-group-true.html
├── home.html
├── network.html
├── screenshot.png
├── service-group-false.html
├── service-group-true.html
├── service.html
└── viewpassword.html
启动后可以直接使用 https://IP:PORT 访问。
相关资料
- 官方文档 https://nezha.wiki/guide/dashboard.html
- nezha-agent docker 版 https://github.com/Redamancy2319/nezha-agent
- NezhaDash https://github.com/hamster1963/nezha-dash
- nezha-agent-rs https://github.com/GenshinMinecraft/nezha-agent-rs