|
|
| (未显示同一用户的4个中间版本) |
| 第1行: |
第1行: |
| = BandwagonHost安装哪吒监控(Nezha Monitoring)+ Nginx 反代 + HTTPS 完整教程 =
| |
|
| |
|
| === 一、什么是哪吒监控(Nezha Monitoring) ===
| |
| [https://nezha.wiki/ 哪吒监控(Nezha Monitoring)]是一款开源、自托管、轻量级的服务器与网站实时监控和运维工具。它支持通过 Dashboard 查看系统状态、资源使用情况,并通过 Agent 采集被监控主机数据。
| |
|
| |
| 在本文中,我们将一步一步教你如何从零开始在[https://go.pigcc.com/bwh BandwagonHost(搬瓦工)] 机器上使用docker安装与部署哪吒监控(Nezha Monitoring)系统的 Dashboard 面板,使用nginx反代Dashboard,并配合 Agent 安装与基本配置内容。
| |
|
| |
| === 二、部署前的准备 ===
| |
|
| |
| ==== 1、服务器与网络条件: ====
| |
|
| |
| * 一台 [https://go.pigcc.com/bwh BandwagonHost(搬瓦工)] '''或'''者其他可以访问公网的服务器
| |
| * 服务器防火墙和安全策略需允许 Dashboard 使用的端口(默认是 8008)
| |
| * 推荐的规格:单核 + 512MB 内存 对于大部分场景足够。
| |
|
| |
| ==== 2、域名设置 ====
| |
|
| |
| * 一个已设置好 A 记录 指向 Dashboard 服务器 IP 的域名
| |
| * 如果面板端使用 CDN,还建议准备第二个域名用于 Agent 通信(不通过 CDN) [[File:Dns解析域名.png|border|frameless|800x800px]]
| |
|
| |
| === 三、安装 Dashboard 面板 ===
| |
|
| |
| ==== 1. 运行官方安装脚本 ====
| |
| 在你的 Dashboard 服务器终端执行以下命令来获取并运行官方安装脚本:<syntaxhighlight lang="bash">
| |
| curl -L https://raw.githubusercontent.com/nezhahq/scripts/refs/heads/main/install.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh
| |
| </syntaxhighlight>如果你的服务器位于中国大陆,可以使用镜像:<syntaxhighlight lang="bash">
| |
| curl -L https://gitee.com/naibahq/scripts/raw/main/install.sh -o nezha.sh && chmod +x nezha.sh && sudo CN=true ./nezha.sh
| |
| </syntaxhighlight>[[File:哪吒面板bash安装步骤1.png|frameless|800x800px]]
| |
| [[File:哪吒面板bash安装步骤2.png|border|frameless|800x800px]]
| |
|
| |
|
| |
| 在浏览器中输入 '''<nowiki>http://your_server_ip:8008</nowiki>''' 可以访问'''哪吒监控的 Web 界面'''。
| |
|
| |
| === 四、使用nginx反代 ===
| |
|
| |
| ==== 1、安装nginx ====
| |
| <syntaxhighlight lang="bash">
| |
| sudo apt update
| |
| sudo apt install -y nginx
| |
| </syntaxhighlight>启动并设置开机自启:<syntaxhighlight lang="bash">
| |
| sudo systemctl start nginx
| |
| sudo systemctl enable nginx
| |
| </syntaxhighlight>
| |
|
| |
| ==== 2、申请证书 ====
| |
|
| |
| # 安装 Certbot + Nginx 插件 Certbot 是 Let's Encrypt 官方推荐的证书管理工具<code>python3-certbot-nginx</code> 插件可以 自动修改 Nginx 配置。<syntaxhighlight>
| |
| sudo apt install certbot python3-certbot-nginx
| |
| </syntaxhighlight>安装完成后,检查版本:<syntaxhighlight lang="bash">
| |
| certbot --version
| |
| </syntaxhighlight>
| |
| # 申请证书<syntaxhighlight lang="bash">
| |
| sudo certbot --nginx -d 你的域名
| |
| </syntaxhighlight>
| |
|
| |
| ==== 3、配置nginx配置文件 ====
| |
| 文件路径一般在 <code>/etc/nginx/sites-available/default</code><syntaxhighlight lang="text">
| |
| server {
| |
| 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;
| |
| }
| |
| </syntaxhighlight>重新加载nginx服务<syntaxhighlight lang="bash">
| |
| sudo systemctl restart nginx
| |
| </syntaxhighlight>
| |
|
| |
| === 五、配置面板 ===
| |
|
| |
| ==== 1、通过域名访问你的面板 ====
| |
| [[File:哪吒面板域名访问.png|frameless|800x800px]]
| |
|
| |
| ==== 2、登录管理后台修改密码 初始账号密码都是 <code>admin</code> ====
| |
| [[File:哪吒面板后端控制台.png|frameless|800x800px]]
| |
| [[File:哪吒面板更改密码.png|frameless|800x800px]]
| |
|
| |
| === 六、添加机器 ===
| |
|
| |
| ==== 1、复制安装命令 ====
| |
| [[File:哪吒面板复制agent指令.png|frameless|800x800px]]
| |
|
| |
| ==== 2、安装Agent ====
| |
| [[File:机器安装Agent指令.png|frameless|800x800px]]
| |
|
| |
| ==== 3、之后就可以在前台看见这个机器了 ====
| |
| [[File:哪吒面板安装完Agent的总控.png|frameless|800x800px]]
| |
|
| |
| ==== 4、可以添加更多的机器 ====
| |
| 将复制的'''指令'''在其他机器上执行就可以实现'''监控其他的机器'''的状态(只需要执行命令即可不需要再次安装面板端)
| |
|
| |
| === 七、最终效果 ===
| |
| [[File:哪吒面板最终效果.png|frameless|800x800px]]
| |
| [[Category:500 常见应用指南 — Application Guides]]
| |