域名解析
面板域名以nz.a.com为例
Cloudflare中添加A记录nz.a.com指向Dashboard 服务器 IP,开启小黄云。a.com域名设置页面——网络,选择开启WebSockets 和 gRPC ;SSL/TLS模式选择完全(严格)。

在服务器中安装 Dashboard
在面板服务器中,运行以下安装脚本(建议以以 Docker 安装。):
curl -L https://raw.githubusercontent.com/nezhahq/scripts/refs/heads/main/install.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh以 Docker 安装为例,安装完成后按提示输入以下信息:
请输入站点标题:- 自定义站点标题。请输入暴露端口:- 公开访问端口(默认 8008,可自定义)。请指定后台语言:- 选择语言偏好。
输入完成后,等待拉取 Docker 镜像。安装结束后,如果一切正常,你可以通过域名和端口号访问 Dashboard,例如:http://nz.a.com:9999
如果需要再次运行安装脚本,可输入以下命令:
./nezha.sh打开管理脚本。
登录到 Dashboard 配置界面
后台管理界面的路径为 /dashboard,你只需访问:http://nz.a.com:9999/dashboard
首次登录的默认用户名和密码均为 admin。
反向代理
1panel面板中新建反向代理网站,网站 —— 创建网站 —— 反向代理,主域名填写nz.a.com,代理地址填写localhost:9999
证书页面自行设置Acme账户、DNS账户为nz.a.com申请证书。
网站页面点击nz.a.com进入网站设置,开启https。
点击配置文件,最下方添加以下代码,保存并重载。

# upstream 配置
upstream dashboard {
keepalive 512;
server localhost:9999;
}打开网站 —— 反向代理 —— 源文,使用以下代码替换原内容,点击确认。至此,反向代理设置完成。

location ^~ / {
proxy_pass http://localhost:9999;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header nz-realip $http_cf_connecting_ip;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_buffer_size 128k;
proxy_buffers 4 128k;
proxy_busy_buffers_size 256k;
proxy_max_temp_file_size 0;
add_header X-Cache $upstream_cache_status;
add_header Cache-Control no-cache;
proxy_ssl_server_name off;
proxy_ssl_name $proxy_host;
add_header Strict-Transport-Security "max-age=31536000";
}
underscores_in_headers on;
set_real_ip_from 0.0.0.0/0; # CDN 回源 IP 地址段
real_ip_header CF-Connecting-IP; # CDN 私有 header,此处为 CloudFlare 默认
# gRPC 服务
location ^~ /proto.NezhaService/ {
grpc_set_header Host $host;
grpc_set_header nz-realip $http_CF_Connecting_IP;
grpc_read_timeout 600s;
grpc_send_timeout 600s;
grpc_socket_keepalive on;
client_max_body_size 10m;
grpc_buffer_size 4m;
grpc_pass grpc://dashboard;
}
# WebSocket 服务
location ~* ^/api/v1/ws/(server|terminal|file)(.*)$ {
proxy_set_header Host $host;
proxy_set_header nz-realip $http_cf_connecting_ip;
proxy_set_header Origin https://$host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_pass http://localhost:9999;
}安装Agent
打开地址nz.a.com ,点击登录初始用户名、密码均为admin,登录后立即进入管理页面点击头像 —— 个人信息 —— 更新个人资料修改用户名和密码。
点击安装命令,选择对应的系统到SSH界面进行安装。

添加TCP-Ping延迟测试
全国各省份三网 TCP-Ping IPv4 地址:https://www.nodeseek.com/post-68572-1
全国各省份三网 TCP-Ping IPv6 地址:https://www.nodeseek.com/post-129987-1
以浙江移动为例,服务页面创建服务,名称:浙江移动,目标:zj-cm-v4.ip.zstaticcdn.com:80,类型:TCPing
添加telegram通知
通知页面点击“+”,创建通知,名称自定,URL填写https://api.telegram.org/bot<你的机器人Token>/sendMessage?chat_id=<你的用户ID>&text=#NEZHA#,将 <你的机器人Token> 和 <你的用户ID> 替换为实际值。
获取 URL 参数
获取机器人 Token:与 @BotFather 对话,发送/newbot创建新机器人,获取 Token。
获取用户 ID:与 @userinfobot 对话,获取你的用户 ID。
与机器人对话:先与新创建的机器人发送一条消息,确保机器人可以发送消息给你。
分组——通知,页面点击“+”,编辑通知分组,名称自定,通知勾选提前创建的telegram通知,确认即可。
警报规则参考哪吒官方文档,以离线通知为例:
通知——警报规则,点击“+”,创建警报规则,名称:离线通知,规则:[{"Type": "offline", "Duration": 10}],通知组:勾选
telegram通知,启用:勾选,点击确认。
面板设置完成,可至服务器页面,点击安装命令,根据系统选择安装命令前往被控vps运行。
注:被控端禁用网页SSH
sed -i 's/disable_command_execute: false/disable_command_execute: true/' /opt/nezha/agent/config.yml && systemctl restart nezha-agent卸载 Agent
卸载 Agent 包括停止服务、卸载服务,以及删除相关文件。以下是 Ubuntu 系统的卸载步骤:
停止并卸载服务:
cd /opt/nezha/agent/
./nezha-agent service uninstall删除 Agent 文件夹:
rm -rf /opt/nezha/agent/如果安装了多个服务并想要全部卸载,可以使用 Agent 安装脚本的卸载功能:
./agent.sh uninstall重新安装并指定 Agent 的 UUID
添加参数 UUID 让新的 Agent 连接后会继承原有的服务器记录和配置。
操作步骤
复制服务器的 UUID
进入 Dashboard,找到目标服务器并获取其对应的 UUID。生成安装命令并添加 UUID
在生成的安装命令中,添加NZ_UUID=服务器的UUID参数。这样可以确保 Agent 正确绑定到指定的服务器记录。确认是否卸载旧 Agent
如果服务器上已有 Agent,请确保卸载旧的 Agent,避免重复注册或冲突。
示例安装命令
以下是一个带有 UUID 参数的完整安装命令示例:
curl -L https://raw.githubusercontent.com/nezhahq/scripts/main/agent/install.sh -o agent.sh && chmod +x agent.sh && env NZ_SERVER=dashboard.example.com:8008 NZ_TLS=false NZ_CLIENT_SECRET=EXAMPLE NZ_UUID=your_server_uuid ./agent.sh将 your_server_uuid 替换为目标服务器的实际 UUID。