哪吒监控(Nezha Monitoring)是一款开源、自托管、轻量级的服务器与网站实时监控和运维工具。它支持通过 Dashboard 查看系统状态、资源使用情况,并通过 Agent 采集被监控主机数据。
在本文中,我们将一步一步教你如何从零开始在BandwagonHost 搬瓦工机器上使用docker安装与部署哪吒监控(Nezha Monitoring)系统的 Dashboard 面板,使用nginx反代Dashboard,并配合 Agent 安装与基本配置内容。
在开始部署之前,你需要准备以下环境:
一个已设置好 A 记录 指向 Dashboard 服务器 IP 的域名
如果使用 CDN,还建议准备第二个域名用于 Agent 通信(不通过 CDN)

在你的 Dashboard 服务器终端执行以下命令来获取并运行官方安装脚本:
bashcurl -L https://raw.githubusercontent.com/nezhahq/scripts/refs/heads/main/install.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh
另外:如果你的服务器位于中国大陆,可以使用镜像:
bashcurl -L https://gitee.com/naibahq/scripts/raw/main/install.sh -o nezha.sh && chmod +x nezha.sh && sudo CN=true ./nezha.sh


在浏览器中输入 http://your_server_ip:8008 可以访问访问哪吒监控的 Web 界面。
具体参考往期文章 https://pigcc.com/post/6
具体参考往期文章 https://pigcc.com/post/6 安装nginx申请证书
或者往期文章 https://pigcc.com/post/16 对证书进行统一管理
文件路径一般在 /etc/nginx/sites-available/default
textserver { listen 443 ssl http2; listen [::]:443 ssl http2; server_name dashboard.example.com; # 替换为你的域名 ssl_certificate /data/letsencrypt/fullchain.pem; # 域名证书路径 ssl_certificate_key /data/letsencrypt/key.pem; # 域名私钥路径 ssl_stapling on; ssl_session_timeout 1d; ssl_session_cache shared:SSL:10m; # 如果与其他配置冲突,请注释此项 ssl_protocols TLSv1.2 TLSv1.3; underscores_in_headers on; # grpc 相关 location ^~ /proto.NezhaService/ { grpc_set_header Host $host; grpc_set_header nz-realip $remote_addr; 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 $remote_addr; 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://127.0.0.1:8008; } # web location / { proxy_set_header Host $host; proxy_set_header nz-realip $remote_addr; proxy_read_timeout 3600s; proxy_send_timeout 3600s; proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; proxy_max_temp_file_size 0; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://127.0.0.1:8008; } } upstream dashboard { server 127.0.0.1:8008; keepalive 512; }
bashsudo nginx -t
#nginx: [warn] "ssl_stapling" ignored, no OCSP responder URL in the certificate "/etc/letsencrypt/live/域名/fullchain.pem"这个警告不影响使用
bashsudo systemctl restart nginx

admin




将复制的链接在其他机器上执行就可以实现监控其他的机器的状态
可以监控所有添加的机器的状态

以TG通知为例:


URL:
https://api.telegram.org/bot<机器人token>/sendMessage?chat_id=<会话id>&text=#NEZHA#
之后点击确认
如果成功就可以在tg看见消息

这样通知方式添加完毕
添加报警规则



警告
上图没有点击启用,需要点击启用之后点击确认,如已经确认可以点击修改
之后我们对服务器执行关机,测试掉线通知 可以成功

更多的警报规则可以查看官方文档:https://nezha.wiki/guide/notifications.html#%E8%AD%A6%E6%8A%A5%E8%A7%84%E5%88%99%E8%AF%B4%E6%98%8E
添加服务


之后再机器详情网络中就可以看见tcp网络波动了
需要等会才会有折线生成,下图是我之前设置好的

如果需要添加更多的需要给每个添加一个服务
例如 : 三个运营商需要添加三个服务
如果觉得官方的样式不符合你的审美,需要添加自定义的样式可以在:


