-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
1 changed file
with
93 additions
and
151 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,184 +1,126 @@ | ||
--- | ||
title: Kutt 开源的网址缩短程序 | ||
title: ServerStatus 多服务器云监控 | ||
tags: | ||
- 程序 | ||
- 监控 | ||
categories: | ||
- 资源分享 | ||
date: 2023-11-02 00:00:00 | ||
--- | ||
|
||
> Kutt 是一个开源的短网址程序,有了它可以在分享一些很长的链接的时候,进行缩短链接,使得分享 URL 更简洁。支持容器部署,虽是英文界面,但操作很简单,感兴趣的小伙伴可以试一下~ | ||
> 去不图床数据托管量已超过 23 万,有一些小伙伴反馈说外链速度慢了些,于是杜老师有增加几个节点。由于是自建 CDN,为了保障外链稳定,设置了云监控,同时将该工具分享给需要的小伙伴们! | ||
<!-- more --> | ||
|
||
## 支持特性 | ||
## 工具介绍 | ||
|
||
1. 开源免费; | ||
通过下方截图可以看出,去不图床托管图片数超过了 23 万,数据占用超过了 93G。有一些小伙伴反馈说外链速度慢了些,于是杜老师有增加几个节点。由于是自建 CDN,为了保障外链稳定,设置了云监控,ServerStatus 中文版是一个酷炫高逼格的云探针、服务器云监控、多服务器探针: | ||
|
||
2. 自定义域支持; | ||
{% gallery %} | ||
![](https://cdn.dusays.com/2023/11/642-1.jpg) | ||
{% endgallery %} | ||
|
||
3. 缩短链接自定义 URL; | ||
## 配置文件 | ||
|
||
4. 设置链接密码; | ||
|
||
5. 设置链接描述; | ||
|
||
6. 链接过期时间; | ||
|
||
7. 查看、编辑、删除、管理链接; | ||
|
||
8. 管理员帐户可查看、删除、禁止链接。 | ||
|
||
## 程序部署 | ||
|
||
如果常规安装的话需要安装 Node.js/PostgreSQL/Redis 等,所以用 Docker 来安装这个是最简单的。将下方的代码保存为`.env`: | ||
ServerStatus 在启用服务之前,需先通过配置文件设置监控对象,将下面的内容根据需求调整,保存为 `serverstatus-config.json`: | ||
|
||
``` | ||
# App port to run on | ||
PORT=3000 | ||
# The name of the site where Kutt is hosted | ||
SITE_NAME=Kutt | ||
# The domain that this website is on | ||
DEFAULT_DOMAIN=localhost:3000 | ||
# Generated link length | ||
LINK_LENGTH=6 | ||
# Postgres database credential details | ||
DB_HOST=postgres | ||
DB_PORT=5432 | ||
DB_NAME=postgres | ||
DB_USER= | ||
DB_PASSWORD= | ||
DB_SSL=false | ||
# Redis host and port | ||
REDIS_HOST=redis | ||
REDIS_PORT=6379 | ||
REDIS_PASSWORD= | ||
REDIS_DB= | ||
# Disable registration | ||
DISALLOW_REGISTRATION=false | ||
# Disable anonymous link creation | ||
DISALLOW_ANONYMOUS_LINKS=false | ||
# The daily limit for each user | ||
USER_LIMIT_PER_DAY=50 | ||
# Create a cooldown for non-logged in users in minutes | ||
# Set 0 to disable | ||
NON_USER_COOLDOWN=0 | ||
# Max number of visits for each link to have detailed stats | ||
DEFAULT_MAX_STATS_PER_LINK=5000 | ||
# Use HTTPS for links with custom domain | ||
CUSTOM_DOMAIN_USE_HTTPS=false | ||
# A passphrase to encrypt JWT. Use a long and secure key. | ||
JWT_SECRET=securekey | ||
# Admin emails so they can access admin actions on settings page | ||
# Comma seperated | ||
ADMIN_EMAILS= | ||
# Invisible reCaptcha secret key | ||
# Create one in https://www.google.com/recaptcha/intro/ | ||
RECAPTCHA_SITE_KEY= | ||
RECAPTCHA_SECRET_KEY= | ||
# Google Cloud API to prevent from users from submitting malware URLs. | ||
# Get it from https://developers.google.com/safe-browsing/v4/get-started | ||
GOOGLE_SAFE_BROWSING_KEY= | ||
# Your email host details to use to send verification emails. | ||
# More info on http://nodemailer.com/ | ||
# Mail from example "Kutt <[email protected]>". Leave empty to use MAIL_USER | ||
MAIL_HOST= | ||
MAIL_PORT= | ||
MAIL_SECURE=true | ||
MAIL_USER= | ||
MAIL_FROM= | ||
MAIL_PASSWORD= | ||
# The email address that will receive submitted reports. | ||
REPORT_EMAIL= | ||
# Support email to show on the app | ||
CONTACT_EMAIL= | ||
{ | ||
"servers": | ||
[ | ||
{ | ||
"username": "s01", | ||
"name": "vps-1", | ||
"type": "kvm", | ||
"host": "chengdu", | ||
"location": "🇨🇳", | ||
"password": "USER_DEFAULT_PASSWORD", | ||
"monthstart": 1 | ||
}, | ||
], | ||
"watchdog": | ||
[ | ||
{ | ||
"name": "服务器负载高监控,排除内存大于32G物理机,同时排除俄勒冈机器", | ||
"rule": "cpu>90&load_1>4&memory_total<33554432&name!='俄勒冈'", | ||
"interval": 600, | ||
"callback": "https://yourSMSurl" | ||
}, | ||
{ | ||
"name": "服务器内存使用率过高监控", | ||
"rule": "(memory_used/memory_total)*100>90", | ||
"interval": 600, | ||
"callback": "https://yourSMSurl" | ||
}, | ||
{ | ||
"name": "服务器宕机告警,排出俄勒冈,排除s02", | ||
"rule": "online4=0&online6=0&name!='俄勒冈'&username!='s02'", | ||
"interval": 600, | ||
"callback": "https://yourSMSurl" | ||
}, | ||
{ | ||
"name": "DDOS和CC攻击监控", | ||
"rule": "tcp_count>600", | ||
"interval": 300, | ||
"callback": "https://yourSMSurl" | ||
}, | ||
{ | ||
"name": "服务器月出口流量999GB告警", | ||
"rule": "(network_out-last_network_out)/1024/1024/1024>999", | ||
"interval": 3600, | ||
"callback": "https://yourSMSurl" | ||
}, | ||
{ | ||
"name": "你可以组合任何已知字段的表达式", | ||
"rule": "(hdd_used/hdd_total)*100>95", | ||
"interval": 1800, | ||
"callback": "https://yourSMSurl" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
在同级目录下,将下方的代码保存为 `docker-compose.yml`: | ||
杜老师收集了几个参数作用,供小伙伴参考: | ||
|
||
``` | ||
version: "3" | ||
services: | ||
kutt: | ||
image: kutt/kutt | ||
depends_on: | ||
- postgres | ||
- redis | ||
command: ["./wait-for-it.sh", "postgres:5432", "--", "npm", "start"] | ||
ports: | ||
- "3000:3000" | ||
env_file: | ||
- .env | ||
environment: | ||
DB_HOST: postgres | ||
DB_NAME: kutt | ||
DB_USER: user | ||
DB_PASSWORD: pass | ||
REDIS_HOST: redis | ||
redis: | ||
image: redis:6.0-alpine | ||
volumes: | ||
- redis_data:/data | ||
postgres: | ||
image: postgres:12-alpine | ||
environment: | ||
POSTGRES_USER: user | ||
POSTGRES_PASSWORD: pass | ||
POSTGRES_DB: kutt | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
volumes: | ||
redis_data: | ||
postgres_data: | ||
``` | ||
| 参数 | 作用 | | ||
| - | - | | ||
! rule | 可设置为任何已知字段的表达式 | | ||
! interval | 最小通知间隔 | | ||
! callback | 可自定义为 POST 方法的 URL,告警内容将拼接其后并发起回调 | | ||
! callback Telegram | https://api.telegram.org/bot<Token>/sendMessage?parse_mode=HTML&disable_web_page_preview=true&chat_id=<ID>&text= | | ||
! callback Server酱 | https://sctapi.ftqq.com/<Token>.send?title=ServerStatus&desp= | | ||
! callback PushDeer | https://api2.pushdeer.com/message/push?pushkey=<Token>&text= | | ||
! callback BasicAuth | https://USER:PASS@URL/api/push?message= | | ||
|
||
## 启用服务 | ||
## 部署方法 | ||
|
||
修改`.env` 中 `DEFAULT_DOMAIN=localhost:3000` 值,将 `localhost` 改为域名,不然访问时会跳转出错。并确保邮箱相关的配置正确: | ||
Server 服务端,首先在配置文件同级目录执行 `mkdir serverstatus-monthtraffic` 创建目录,然后执行下方命令即可启用服务: | ||
|
||
``` | ||
MAIL_HOST= | ||
MAIL_PORT= | ||
MAIL_SECURE=true | ||
MAIL_USER= | ||
MAIL_FROM= | ||
MAIL_PASSWORD= | ||
docker run -d --restart=always --name=serverstatus -v ~/serverstatus-config.json:/ServerStatus/server/config.json -v ~/serverstatus-monthtraffic:/usr/share/nginx/html/json -p 80:80 -p 35601:35601 cppla/serverstatus:latest | ||
``` | ||
|
||
然后通过下方命令启动服务: | ||
Client 客户端,客户端不支持用 Docker 部署,直接使用下方命令即可自动部署: | ||
|
||
``` | ||
docker-compose up -d | ||
wget --no-check-certificate -qO client-linux.py 'https://raw.githubusercontent.com/penndu/ServerStatus/master/clients/client-linux.py' && nohup python3 client-linux.py SERVER={$SERVER} USER={$USER} PASSWORD={$PASSWORD} > /dev/null 2>&1 & | ||
``` | ||
|
||
## 注意事项 | ||
## 不同主题 | ||
|
||
默认监控页面如下,点击服务器项可以查看详细信息,包含内存、硬盘、网络情况等等,页面每三秒会自动刷新: | ||
|
||
{% gallery %} | ||
![](https://cdn.dusays.com/2023/11/642-2.jpg) | ||
{% endgallery %} | ||
|
||
Kutt 默认是没有管理员用户的,需要通过邮箱注册,所以需要`.env` 里邮箱相关的内容都配置正确。 | ||
这个是用户自定义模板,如需用该模板,需要手动部署 Server 服务端,无法使用 Docker 的方式部署: | ||
|
||
注册账号时始终提示失败 `an error occurred`,虽然不影响短链接的生成及使用,但无法登录管理员后台还是很难受的。 | ||
{% gallery %} | ||
![](https://cdn.dusays.com/2023/11/642-3.jpg) | ||
{% endgallery %} | ||
|
||
注册失败实际是没有发邮件激活成功,通过在作者的 Issues 里发现了有很多人大量反馈此问题,应该是对接 SMTP 服务的 bug。 | ||
这款是杜老师目前用的主题「目前部署在内网中,暂时无法公布演示链接」 | ||
|
||
这种方式可通过登录 PostgreSQL 容器,查找到对应用户验证 Token,再访问 URL 激活即可。 | ||
{% gallery %} | ||
![](https://cdn.dusays.com/2023/11/642-4.jpg) | ||
{% endgallery %} |