添加多语言、修改文章结构、新增安装指南

This commit is contained in:
hhhkkk520
2022-05-17 14:26:01 +02:00
parent 705f805b26
commit bc5ba38697
23 changed files with 734 additions and 1762 deletions
+53
View File
@@ -0,0 +1,53 @@
# Theme Config: Algolia Search
The `themeConfig.algolia` option allows you to use [Algolia DocSearch](https://docsearch.algolia.com). To enable it, you need to provide at least appId, apiKey and indexName:
```js
module.exports = {
themeConfig: {
algolia: {
appId: 'your_app_id',
apiKey: 'your_api_key',
indexName: 'index_name'
}
}
}
```
For more options, check out [Algolia DocSearch's documentation](https://docsearch.algolia.com/docs/api/). You can pass any extra option alongside other options, e.g. passing `searchParameters`:
```js
module.exports = {
themeConfig: {
algolia: {
appId: 'your_app_id',
apiKey: 'your_api_key',
indexName: 'index_name',
searchParameters: {
facetFilters: ['tags:guide,api']
}
}
}
}
```
## Internationalization (i18n)
If you have multiple locales in your documentation and you have defined a `locales` object in your `themeConfig`:
```js
module.exports = {
themeConfig: {
locales: {
// ...
},
algolia: {
appId: 'your_app_id',
apiKey: 'your_api_key',
indexName: 'index_name'
}
}
}
```
VitePress will automatically add a `lang` _facetFilter_ to the `searchParameters.facetFilter` array with the correct language value. Algolia automatically adds the correct facet filter based on the `lang` attribute on the `<html>` tag. This will match search results with the currently viewed language of the page.
+59
View File
@@ -0,0 +1,59 @@
# App Config: Basics
::: tip
The config reference is incomplete since the config format may still receive further changes. For a complete reference of the current available options, refer to [config.ts](https://github.com/vuejs/vitepress/blob/45b65ce8b63bd54f345bfc3383eb2416b6769dc9/src/node/config.ts#L30-L65).
:::
## base
- Type: `string`
- Default: `/`
The base URL the site will be deployed at. You will need to set this if you plan to deploy your site under a sub path, for example, GitHub pages. If you plan to deploy your site to `https://foo.github.io/bar/`, then you should set base to `'/bar/'`. It should always start and end with a slash.
The `base` is automatically prepended to all the URLs that start with `/` in other options, so you only need to specify it once.
```js
module.exports = {
base: '/base/'
}
```
## lang
- Type: `string`
- Default: `en-US`
The `lang` attribute for the site. This will render as a `<html lang="en-US">` tag in the page HTML.
```js
module.exports = {
lang: 'en-US'
}
```
## title
- Type: `string`
- Default: `VitePress`
Title for the site. This will be the suffix for all page titles, and displayed in the navbar.
```js
module.exports = {
title: 'VitePress'
}
```
## description
- Type: `string`
- Default: `A VitePress site`
Description for the site. This will render as a `<meta>` tag in the page HTML.
```js
module.exports = {
description: 'A VitePress site'
}
```
+15
View File
@@ -0,0 +1,15 @@
# Theme Config: Carbon Ads
VitePress has built in native support for [Carbon Ads](https://www.carbonads.net). By defining the Carbon Ads credentials in config, VitePress will display ads on the page.
```js
module.exports = {
themeConfig: {
carbonAds: {
carbon: 'your-carbon-key',
custom: 'your-carbon-custom',
placement: 'your-carbon-placement'
}
}
}
```
+23
View File
@@ -0,0 +1,23 @@
# Theme Config: Homepage
VitePress provides a homepage layout. To use it, specify `home: true` plus some other metadata in your root `index.md`'s [YAML frontmatter](../guide/frontmatter). This is an example of how it works:
```yaml
---
home: true
heroImage: /logo.png
heroAlt: Logo image
heroText: Hero Title
tagline: Hero subtitle
actionText: Get Started
actionLink: /guide/
features:
- title: Simplicity First
details: Minimal setup with markdown-centered project structure helps you focus on writing.
- title: Vue-Powered
details: Enjoy the dev experience of Vue + webpack, use Vue components in markdown, and develop custom themes with Vue.
- title: Performant
details: VitePress generates pre-rendered static HTML for each page, and runs as an SPA once a page is loaded.
footer: MIT Licensed | Copyright © 2019-present Evan You
---
```
+106
View File
@@ -0,0 +1,106 @@
**哪吒监控的被控端服务被称为Agent,本文档将介绍如何在被控端服务器上安装Agent,并与Dashboard连接**
<br/>
## Install Agent using one-click script
目前哪吒监控已支持在WIndows和Linux上一键安装Agent,遵循本文档的步骤,你可以很轻松的在服务器上部署它
<br/>
### 准备工作
---
你需要提前在管理面板中设置好通信域名,此域名不可以接入CDN,这里以前面提到过的示例通信域名 “data.example.com” 来做演示
进入后台管理面板,转到“设置”页,在“未接入CDN的面板服务器域名/IP”项中填入通信域名,然后点击"保存"
<br/>
### Linux一键安装
---
* 首先在管理面板中添加一台服务器
* 点击新添加的服务器旁,绿色的Linux图标按钮,复制一键安装命令
* 在被控端服务器中运行复制的一键安装命令,等待安装完成后返回到Dashboard主页查看服务器是否上线
<br/>
### Windows一键安装
---
* 首先在管理面板中添加一台服务器
* 点击新添加的服务器旁,绿色的Windows图标按钮,复制一键安装命令
* 进入Windows服务器,运行PowerShell,在PowerShell中运行复制的安装命令
* 如遇到确认「执行策略变更」请选择 Y
* 等待安装完成后返回Dashboard主页查看服务器是否上线
<br/>
<br/>
## 其他方式安装Agent
---
<br/>
### Linux安装Agent
---
* 首先在管理面板中添加一台服务器
* 在被控服务器中,运行脚本(位于中国大陆的服务器请使用镜像):
```bash
curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh
```
* 选择“安装监控Agent”
* 输入通信域名,如:”data.example.com“
* 输入面板通信端口,默认为5555
* 输入Agent密钥,Agent密钥在管理面板中添加服务器时生成,可以在管理面板中的“主机”页中找到
* 等待安装完成后返回Dashboard主页查看服务器是否上线
<br/>
### Windows安装Agent
---
- 请参考社区文章:
[哪吒探针 - Windows 客户端安装](https://nyko.me/2020/12/13/nezha-windows-client.html)
<br/>
### OpenWRT安装Agent
---
**如何使 旧版OpenWRT/LEDE 自启动**
- 请参考项目:
[哪吒监控 For OpenWRT](https://github.com/Erope/openwrt_nezha)
<br/>
**如何使 新版OpenWRT 自启动?来自 @艾斯德斯**
* 首先在 release 下载对应的二进制解压 zip 包后放置到 `/root`
* 运行 `chmod +x /root/nezha-agent` 赋予执行权限,然后创建 `/etc/init.d/nezha-service`:
```shell
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
start_service() {
procd_open_instance
procd_set_param command /root/nezha-agent -s 面板通信地址:端口 -p 秘钥 -d
procd_set_param respawn
procd_close_instance
}
stop_service() {
killall nezha-agent
}
restart() {
stop
sleep 2
start
}
```
* 运行 `chmod +x /etc/init.d/nezha-service` 赋予执行权限
* 启动服务: `/etc/init.d/nezha-service enable && /etc/init.d/nezha-service start`
<br/>
<br/>
## 自定义Agent监控项目
---
#### 自定义监控的网卡和硬盘分区
* 执行 `/opt/nezha/agent/nezha-agent --edit-agent-config` 来选择自定义的网卡和分区,然后重启 Agent 即可生效
#### 其他运行参数
通过执行 `./nezha-agent --help` 查看支持的参数,如果你使用了一键脚本安装Agent,可以编辑 `/etc/systemd/system/nezha-agent.service`,在 `ExecStart=` 这一行的末尾加上以下参数
- `--report-delay` 控制系统信息上报的间隔,默认为 1 秒,可以设置为 3 来进一步降低 agent 端系统资源占用(配置区间 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 时,需要启用该项配置)
+103
View File
@@ -0,0 +1,103 @@
### Preparations
----
搭建一个哪吒监控,你需要:
1. 一台可以连接公网的VPS,防火墙和安全策略需要放行8008和5555端口,否则会无法访问和无法接收数据。单核512MB内存的服务器配置就足以满足大多数使用场景
2. 一个已经设置好A记录,指向Dashboard服务器ip的域名
::: tip
如果你想使用CDN,请准备两个域名,一个配置好CDN用作公开访问,CDN需要支持WebSocket协议;另一个域名不要使用CDN,用作Agent端与Dashboard的通信
本文档分别以 "cdn.example.com" 和 "data.example.com" 两个域名来演示
:::
3. 一个Github/Gitee账号
**本文档将以宝塔面板反代面板的过程作为范例,随着未来版本的变化,部分功能的入口可能会发生改变,本文档仅供参考**
<br/>
<br/>
### 获取Github的Client ID和密钥
----
哪吒监控接入Github和Gitee作为后台管理员账号
+ 首先我们需要新建一个验证应用,以Github为例,登陆Github后,打开 https://github.com/settings/developers ,依次选择“OAuth Apps” - “New OAuth App”
`Application name` - 随意填写
`Homepage URL` - 填写面板的访问域名,如:"http://cdn.example.com"
`Authorization callback URL` - 填写回调地址,如:"http://cdn.example.com/oauth2/callback"
+ 点击“Register application”
+ 保存页面中的Client ID,然后点击 “Generate a new client secret“,创建一个新的Client Secret,新建的密钥仅会显示一次,请妥善保存
<br/>
<br/>
### 在服务器中安装Dashboard
---
* 在面板服务器中,运行安装脚本:
```bash
curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh
```
如果你的面板服务器位于中国大陆,可以使用镜像:
````bash
curl -L https://fastly.jsdelivr.net/gh/naiba/nezha@master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo CN=true ./nezha.sh
````
* 等待Docker安装完毕后,分别输入以下值:
`OAuth提供商` - Github或Gitee
`Client ID` - 之前保存的Client ID
`Client Secret` - 之前保存的密钥
`用户名` - Github或Gitee的用户名
`站点标题` - 自定义站点标题
`访问端口` - 公开访问端口,可自定义,默认8008
`Agent的通信端口` - Agent与Dashboard的通信端口,默认5555
* 输入完成后,等待拉取镜像
安装结束后,如果一切正常,此时你可以访问域名+端口号,如 “http://cdn.example.com:8008” 来查看面板
* 将来如果需要再次运行脚本,可以运行:
```bash
./nezha.sh
```
来打开管理脚本
<br/>
<br/>
### 配置反向代理
---
* 在宝塔面板中新建一个站点,域名填写公开访问域名,如 “http://cdn.example.com“ ,然后点击“设置”进入站点设置选项,选择“反向代理” - “新建反向代理”
* 自定义一个代理名称,在下方“目标URL”中填入 `http://127.0.0.1` 然后点击“保存”
* 打开刚刚新建的反向代理右边的“配置文件”,将配置文件替换为以下内容:
````nginx
#PROXY-START/
location / {
proxy_pass http://127.0.0.1:8008;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
}
location ~ ^/(ws|terminal/.+)$ {
proxy_pass http://127.0.0.1:8008;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
#PROXY-END/
````
* 点击“保存”
现在,你应该可以直接使用域名,如:“http://cdn.example.com“ 来访问面板了
<br/>
#### 扩展内容:
* CaddyServer v1(v2 无需特别配置)
```Caddyfile
proxy /ws http://ip:8008 {
websocket
}
proxy /terminal/* http://ip:8008 {
websocket
}
```
<br/>
<br/>
### 在宝塔面板中配置SSL
---
首先,先暂时关闭反向代理
正如在其他网站中配置SSL证书一样,进入站点设置中的“SSL”,你可以选择自动申请 Let´s Encrypt 证书或手动配置已有的证书
完成SSL的设置后,你需要回到 https://github.com/settings/developers ,编辑之前创建的验证应用程序,将之前我们填入的"Homepage URL"和"Authorization callback URL"中的域名全部从`http`改为`https`,如:"https://cdn.example.com" 和 "https://cdn.example.com/oauth2/callback" ,**不更改此项可能会导致你无法登陆面板后台**
+1
View File
@@ -0,0 +1 @@
## What is Nezha Monitoring?