-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a09c18b
commit 64fcffd
Showing
8 changed files
with
296 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,106 @@ | ||
# 反向代理 面板 | ||
|
||
新版本不再区分Dashboard、gRPC端口,只有默认的8008端口。 | ||
|
||
- Nginx 配置 示例 | ||
```nginx | ||
server { | ||
listen 443 ssl http2; | ||
listen [::]:443 ssl http2; | ||
#http2 on; # Nginx > 1.25.1 就把上面的 http2去掉 保留这行 | ||
server_name dashboard.nezha.example; | ||
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默认的 | ||
location ^~ /proto.NezhaService/ { | ||
grpc_set_header Host $host; | ||
grpc_set_header nz-realip $http_CF_Connecting_IP; # 修改为你的CDN提供的私有header,此处为CloudFlare默认的 | ||
grpc_read_timeout 300s; | ||
grpc_send_timeout 300s; | ||
grpc_socket_keepalive on; | ||
grpc_pass grpc://dashboard; | ||
} | ||
location / { | ||
proxy_set_header Host $host; | ||
proxy_set_header Origin https://$host; | ||
proxy_set_header nz-realip $http_CF_Connecting_IP; # 修改为你的CDN提供的私有header,此处为CloudFlare默认的 | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection 'upgrade'; | ||
proxy_read_timeout 3600s; | ||
proxy_send_timeout 3600s; | ||
proxy_pass http://dashboard; | ||
} | ||
# Dashboard 反向代理配置 | ||
|
||
从 V1 版本开始,不再区分 Dashboard 和 gRPC 端口,访问与通信均通过默认的 `8008` 端口。 | ||
|
||
--- | ||
|
||
## Nginx 配置示例 | ||
|
||
以下是使用 Nginx 配置反向代理的示例: | ||
|
||
```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 默认 | ||
location ^~ /proto.NezhaService/ { | ||
grpc_set_header Host $host; | ||
grpc_set_header nz-realip $http_CF_Connecting_IP; # 替换为你的 CDN 提供的私有 header,此处为 CloudFlare 默认 | ||
grpc_read_timeout 300s; | ||
grpc_send_timeout 300s; | ||
grpc_socket_keepalive on; | ||
grpc_pass grpc://dashboard; | ||
} | ||
upstream dashboard { | ||
server localhost:8008; | ||
keepalive 512; | ||
location / { | ||
proxy_set_header Host $host; | ||
proxy_set_header Origin https://$host; | ||
proxy_set_header nz-realip $http_CF_Connecting_IP; # 替换为你的 CDN 提供的私有 header,此处为 CloudFlare 默认 | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection 'upgrade'; | ||
proxy_read_timeout 3600s; | ||
proxy_send_timeout 3600s; | ||
proxy_pass http://dashboard; | ||
} | ||
``` | ||
} | ||
- Caddy 配置 示例 | ||
upstream dashboard { | ||
server localhost:8008; | ||
keepalive 512; | ||
} | ||
``` | ||
|
||
``` | ||
dashboard.nezha.example { | ||
@grpcProto { | ||
path /proto.NezhaService/* | ||
} | ||
reverse_proxy @grpcProto { | ||
header_up Host {host} | ||
header_up nz-realip {http.CF-Connecting-IP} # 替换为你的 CDN 提供的私有 header,此处为 CloudFlare 默认的 | ||
transport http { | ||
versions h2c | ||
read_buffer 4096 | ||
} | ||
to localhost:8008 | ||
--- | ||
|
||
## Caddy 配置示例 | ||
|
||
以下是使用 Caddy 配置反向代理的示例: | ||
|
||
```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 默认 | ||
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 Upgrade {http.upgrade} | ||
header_up Connection "upgrade" | ||
transport http { | ||
read_buffer 16384 | ||
} | ||
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 Upgrade {http.upgrade} | ||
header_up Connection "upgrade" | ||
transport http { | ||
read_buffer 16384 | ||
} | ||
to localhost:8008 | ||
} | ||
} | ||
``` | ||
|
||
--- | ||
|
||
### 配置注意事项 | ||
|
||
1. **调整 Header** | ||
根据您使用的 CDN 服务商,替换 `CF-Connecting-IP` 和相关配置为您的 CDN 提供的私有 header。 | ||
|
||
2. **HTTPS 配置** | ||
确保 SSL 证书路径正确,并已正确配置域名解析。 | ||
|
||
3. **负载调整** | ||
根据服务器性能和访问需求,可调整 `keepalive` 和 `buffer` 设置。 | ||
|
||
``` | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,99 @@ | ||
--- | ||
outline: deep | ||
--- | ||
|
||
# 自定义 Agent 监控项目 | ||
*V0版本,不适用于V1版本* | ||
|
||
## 自定义监控的网卡和硬盘分区 | ||
通过运行参数的配置,您可以灵活调整 Agent 的功能和行为,满足不同场景的监控需求。 | ||
|
||
执行以下命令来选择网卡和分区,然后重启 Agent 即可生效: | ||
--- | ||
|
||
```bash | ||
/opt/nezha/agent/nezha-agent edit | ||
``` | ||
## 运行参数 | ||
|
||
## 其他运行参数 | ||
### 配置参数 | ||
|
||
### 查看支持的参数 | ||
要查看支持的运行参数,请执行以下命令: | ||
```bash | ||
./nezha-agent --help | ||
``` | ||
如果您通过一键脚本安装了 Agent,可以编辑 `/opt/nezha/agent/config.yml` 文件来添加或修改参数。 | ||
同一台服务器可以运行多个 Agent,每个 Agent 配置文件相互独立。 | ||
|
||
### 配置参数 | ||
如果您通过一键脚本安装了 Agent,可以通过编辑系统服务配置来添加或修改参数。编辑文件 `/etc/systemd/system/nezha-agent.service`,并在 `ExecStart=` 行的末尾添加您需要的参数: | ||
|
||
::: tip | ||
如果您需要批量添加参数,可以利用 Dashboard 的计划任务功能。以禁用 Agent 自动更新功能为例,您可以设置一个计划任务。添加以下命令以修改系统服务配置,并触发该任务执行: | ||
```bash | ||
sed -i '/^ExecStart=/ s/$/ --disable-auto-update/' /etc/systemd/system/nezha-agent.service && systemctl daemon-reload | ||
``` | ||
::: | ||
|
||
- `--report-delay`:设置系统信息上报的间隔时间。默认为 1 秒。为了降低系统资源占用,可以设置为 3(有效范围:1-4 秒)。 | ||
- `--skip-conn`:不监控网络连接数。建议在连接数较多或 CPU 资源占用较高的服务器上使用此参数。 | ||
- `--skip-procs`:不监控进程数,有助于降低 Agent 的资源占用。 | ||
- `--disable-auto-update`:禁用 Agent 的**自动更新**功能,增强安全性。 | ||
- `--disable-force-update`:禁用 Agent 的**强制更新**功能,增强安全性。 | ||
- `--disable-command-execute`:禁止在 Agent 上执行任何定时任务或使用在线终端,增强安全性。 | ||
- `--tls`:启用 SSL/TLS 加密。当您使用 nginx 反向代理 Agent 的 gRPC 连接且 nginx 配置了 SSL/TLS 时,应启用此配置。 | ||
- `--use-ipv6-countrycode`:强制使用 IPv6 地址查询国家代码。默认情况下,Agent 使用 IPv4 地址查询国家代码,如果服务器支持 IPv6 且与 IPv4 地址的国家代码不同,可以使用此参数。 | ||
- `--gpu`:启用 GPU 监控。注意:GPU 使用率监控可能需要安装额外的依赖包,详细信息可以参考文档:[启用 GPU 监控](/guide/q9.html)。 | ||
- `--temperature`:启用硬件温度监控。仅支持的硬件有效,部分 VPS 可能无法获取温度信息。 | ||
- `-d` `--debug`:启用调试模式。 | ||
- `-u` `--ip-report-period`:本地IP更新间隔, 如果这个值小于 `--report-delay` 设置的值,那么以 `--report-delay` 的值为准。默认为1800秒(30分钟)。 | ||
- `-k` `--insecure`:禁用证书检查,适用于使用自签证书的场景。 | ||
运行参数及其作用: | ||
|
||
- **`debug:`** | ||
- 当为 `true` 时启用调试模式,记录详细日志。 | ||
|
||
- **`disable_auto_update:`** | ||
- 当为 `true` 时禁用 Agent 的自动更新功能,增强系统稳定性和安全性。 | ||
|
||
- **`disable_command_execute:`** | ||
- 当为 `true` 时禁用在线终端、文件管理和定时任务的执行,提升安全性。 | ||
|
||
- **`disable_force_update:`** | ||
- 当为 `true` 时禁用强制更新功能,仅允许手动更新。 | ||
|
||
- **`disable_nat:`** | ||
- 当为 `true` 时禁用内网穿透功能,保护内网数据。 | ||
|
||
- **`disable_send_query:`** | ||
- 当为 `true` 时禁用 Agent 发起的 `TCP Ping`、`ICMP Ping` 和 `HTTP GET` 请求。 | ||
|
||
- **`gpu:`** | ||
- 当为 `true` 时启用 GPU 监控。 | ||
- 注意:启用 GPU 监控可能需要安装额外依赖,详细信息参考:[启用 GPU 监控](/guide/q9.html)。 | ||
|
||
- **`insecure_tls:`** | ||
- 当为 `true` 时禁用证书检查,适用于使用自签名证书的场景。 | ||
|
||
- **`ip_report_period:`** | ||
- 设置本地 IP 更新间隔时间(秒)。默认值为 `1800` 秒(30 分钟)。 | ||
- 如果该值小于 `report_delay` 设置值,则以 `report_delay` 为准。 | ||
|
||
- **`report_delay:`** | ||
- 设置系统信息上报的时间间隔(秒)。默认值为 `1` 秒,建议设置为 `3` 秒以降低资源占用(有效范围:1-4 秒)。 | ||
|
||
- **`server:`** | ||
- 与 Dashboard 通信的域名或 IP 地址,需包括端口号。 | ||
|
||
- **`skip_connection_count:`** | ||
- 当为 `true` 时禁用网络连接数的监控,适用于高连接数或资源受限的环境。 | ||
|
||
- **`skip_procs_count:`** | ||
- 当为 `true` 时禁用进程数的监控,以降低资源占用。 | ||
|
||
- **`temperature:`** | ||
- 当为 `true` 时启用硬件温度监控(仅支持部分硬件,部分 VPS 可能无法获取温度信息)。 | ||
|
||
- **`tls:`** | ||
- 当为 `true` 时启用 Agent 与 Dashboard 间的通信 SSL/TLS 加密。 | ||
- 如果 Agent 使用 Nginx 反向代理且启用了 SSL/TLS 配置,请开启此选项。 | ||
|
||
- **`use_gitee_to_upgrade:`** | ||
- 当为 `true` 时使用 Gitee 仓库作为自动更新源,对中国大陆服务器更为友好。 | ||
|
||
- **`use_ipv6_country_code:`** | ||
- 当为 `true` 时强制使用 IPv6 地址查询国家代码(默认使用 IPv4)。 | ||
|
||
- **`uuid:`** | ||
- 当前 Agent 的唯一标识参数,用于 Dashboard 识别数据来源。 | ||
- 若需替换 Dashboard 中已存在的 Agent,可以手动设置此参数。 | ||
|
||
--- | ||
|
||
## 保存生效 | ||
|
||
在修改配置文件中的参数后,需要重新启动 Agent 服务以使更改生效。具体操作如下: | ||
|
||
1. **重新启动服务** | ||
运行以下命令重新启动默认的第一个 Agent 服务: | ||
```shell | ||
sudo systemctl restart nezha-agent.service | ||
``` | ||
|
||
2. **多 Agent 服务的情况** | ||
如果同一服务器上运行了多个 Agent 服务,请先列出所有 Agent 服务的名称: | ||
```shell | ||
sudo systemctl list-units --type=service | grep nezha-agent | ||
``` | ||
然后分别使用以下命令重新启动对应的 Agent 服务: | ||
```shell | ||
sudo systemctl restart <service-name> | ||
``` | ||
将 `<service-name>` 替换为实际的服务名称,例如 `[email protected]`。 |
Oops, something went wrong.