哪吒监控部署

开始

博主浏览 Github 无意中,发现了一个好用的服务器监控开源项目,功能强大,可以实时对服务器运行异常监控,随手写下此篇哪吒监控部署安装保姆级教程文章,希望看到这篇文章对你有所帮助,以及部署可能容易踩坑的地方。




部署服务端

遇到更新软件源报错,或未进行系统安装配置,可以查看下方帮助,已安装好Centos7系统,通过SSH登入上服务器,运行下列脚本开始安装部署。

Centos7 系统
Centos7 安装完成后,部署机系统参数示列

环境准备

  • 一台云服务器,配置建议1C1G及以上,服务器有一个公网 ipv4 或 ipv6,安装任意Linux发行版本,文章所安装 Centos7.9 系统环境部署。
  • 一个域名,把公网ipv4解析到注册域名,防火墙放行安全策略组,需使用 8008 / 5555 端口。
  • 注册 GithubGitlabGitee 开源社区帐号用于面板控制台登入认证。

安装所用工具

开始部署,首先安装一下所需的工具。

# 更新系统软件
yum update

# 安装软件工具
yum install curl net-tools -y

执行安装命令

如受网络影响,选择所在区域脚本执行。

国外机推荐执行此脚本

curl -L https://raw.githubusercontent.com/nezhahq/scripts/main/install.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh

国内机推荐执行此脚本

curl -L "https://cdn.jsdelivr.net/gh/naiba/nezha@master/script/install.sh -o nezha.sh" && chmod +x nezha.sh && sudo CN=true ./nezha.sh

执行完成上面代码你将看到以下界面, 安装方式随机选择哪吒监控脚本管理菜单,输入 1 选择安装面板端。

哪吒监控安装脚本页面
执行安装脚本后

然后依次通过脚本依次输入以下参数,前面

  • OAuth2 提供商 (Github/Gitlab/Jihulab/Gitee)
  • Oauth2 应用的 Client ID
  • Oauth2 应用的 Client Secret
  • GitHub/Gitee 用户登录名
  • 自定义站点标题
  • 站点访问的端口
  • 客户端对接的PRC端口

配置反向代理

 Tips
以下选择任意一种方式,进行反向代理控制面板,然后可以通过域名访问到控制面板进行下一步配置。

这里以 exple.58r.my 与 data.58r.my

Nginx 配置示列 (方法一)

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    # http2 on; # Nginx > 1.25.1,请注释上面两行,启用此行

    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;
    set_real_ip_from 0.0.0.0/0; # 替换为你的 CDN 回源 IP 地址段
    real_ip_header CF-Connecting-IP; # 替换为你的 CDN 提供的私有 header,此处为 CloudFlare 默认
    # 如果你使用nginx作为最外层,把上面两行注释掉

    # grpc 相关    
    location ^~ /proto.NezhaService/ {
        grpc_set_header Host $host;
        grpc_set_header nz-realip $http_CF_Connecting_IP; # 替换为你的 CDN 提供的私有 header,此处为 CloudFlare 默认
        # grpc_set_header nz-realip $remote_addr; # 如果你使用nginx作为最外层,就把上面一行注释掉,启用此行
        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; # 替换为你的 CDN 提供的私有 header,此处为 CloudFlare 默认
        # proxy_set_header nz-realip $remote_addr; # 如果你使用nginx作为最外层,就把上面一行注释掉,启用此行
        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 $http_cf_connecting_ip; # 替换为你的 CDN 提供的私有 header,此处为 CloudFlare 默认
        # proxy_set_header nz-realip $remote_addr; # 如果你使用nginx作为最外层,就把上面一行注释掉,启用此行
        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; # 如果你使用nginx作为最外层,就启用此行避免无法正确读取访问的协议
        proxy_pass http://127.0.0.1:8008;
    }
}

upstream dashboard {
    server 127.0.0.1:8008;
    keepalive 512;
}


Caddy 配置示例 (方法二)

dashboard.example.com {
    @grpcProto {
        path /proto.NezhaService/*
    }

    reverse_proxy @grpcProto {
        header_up Host {host}
        header_up nz-realip {http.CF-Connecting-IP} # 替换为你的 CDN 提供的私有 header,此处为 CloudFlare 默认
        # header_up nz-realip {remote_host} # 如果你使用caddy作为最外层,就把上面一行注释掉,启用此行
        transport http {
            versions h2c
            read_buffer 4096
        }
        to localhost:8008
    }

    reverse_proxy {
        header_up Host {host}
        header_up Origin https://{host}
        header_up nz-realip {http.CF-Connecting-IP} # 替换为你的 CDN 提供的私有 header,此处为 CloudFlare 默认
        # header_up nz-realip {remote_host} # 如果你使用caddy作为最外层,就把上面一行注释掉,启用此行
        transport http {
            read_buffer 16384
        }
        to localhost:8008
    }
}

配置证书 SSL

希望以上内容对你有所帮助
- 作者:MarTaSai
- 博客:CheesiT 's blog
版权声明:写作不易,转载文章内容记得注明本文地址以及作者,文章采用 CC BY-NC-SA 4.0 协议。
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇