59 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#### 反向代理 gRPC 端口(支持 Cloudflare CDN
使用 Nginx 或者 Caddy 反向代理 gRPC
- Nginx 配置
```nginx
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name data.example.com; # 你的 Agent 连接 Dashboard 的域名
ssl_certificate /data/letsencrypt/fullchain.pem; # 你的域名证书路径
ssl_certificate_key /data/letsencrypt/key.pem; # 你的域名私钥路径
underscores_in_headers on;
location / {
grpc_read_timeout 300s;
grpc_send_timeout 300s;
grpc_socket_keepalive on;
grpc_pass grpc://grpcservers;
}
}
upstream grpcservers {
server localhost:5555;
keepalive 1024;
}
```
- Caddy 配置
```
data.example.com:443 { # 你的 Agent 连接 Dashboard 的域名
reverse_proxy {
to localhost:5555
transport http {
versions h2c 2
}
}
}
```
Dashboard 面板端配置
- 首先登录面板进入管理后台 打开设置页面,在 `未接入CDN的面板服务器域名/IP` 中填入上一步在 Nginx 或 Caddy 中配置的域名 比如 `data.example.com` ,并保存。
- 然后在面板服务器中,打开 /opt/nezha/dashboard/data/config.yaml 文件,将 `proxygrpcport` 修改为 Nginx 或 Caddy 监听的端口,比如上一步设置的 `443` ;因为我们在 Nginx 或 Caddy 中开启了 SSL/TLS所以需要将 `tls` 设置为 `true` ;修改完成后重启面板。
Agent 端配置
- 登录面板管理后台,复制一键安装命令,在对应的服务器上面执行一键安装命令重新安装 agent 端即可。
开启 Cloudflare CDN可选
根据 Cloudflare gRPC 的要求gRPC 服务必须侦听 443 端口 且必须支持 TLS 和 HTTP/2。
所以如果需要开启 CDN必须在配置 Nginx 或者 Caddy 反向代理 gRPC 时使用 443 端口并配置证书Caddy 会自动申请并配置证书)。
- 登录 Cloudflare选择使用的域名。打开 `网络` 选项将 `gRPC` 开关打开,打开 `DNS` 选项,找到 Nginx 或 Caddy 反代 gRPC 配置的域名的解析记录,打开橙色云启用 CDN。