Repository navigation
Conversation
Member
|
此仓库是插件模板,请不要在这里提交具体插件的 PR。 |
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Halo IP 流量监控插件
面向 Halo 2.25.x 的请求级实时流量监控插件。插件通过 Halo
AdditionalWebFilter记录前台 HTTP 请求,在 Console 中提供 IP 排名、访问时间柱状图、流量统计与异常告警。已实现
.env、wp-admin、phpmyadmin、actuator等常见扫描路径。POST /login登录失败;同一 IP 在指定窗口内达到阈值后立即返回403并进入封禁列表。Set-Cookie、认证挑战等敏感响应头在详情中显示为[REDACTED]。安装
确保 Halo 版本为
2.25.0或更高的 2.25.x。打开 Halo Console -> 插件 -> 安装插件。
上传:
启用插件,然后从左侧 安全 -> IP 流量监控 进入仪表盘。
反向代理 IP 配置
直连 Halo 时保持“信任反向代理 IP 请求头”关闭。使用 Nginx 时,先确保代理会覆盖请求头:
确认请求不会绕过反向代理直连 Halo 后,再在插件设置中开启信任代理请求头。
配置项
127.0.0.1、::1当前
1.2.0的统计、请求明细与封禁状态采用进程内滚动窗口:插件重载或 Halo 重启后从空状态开始。配置中的白名单和阈值由 Halo 保存。构建与测试
需要 JDK 21、Node.js 和 pnpm 9.15.9。建议把源码放在纯 ASCII 路径下,Windows 上部分 Gradle test worker 对中文 classpath 处理异常。
单独检查 UI:
真实 Halo 运行时 smoke test:
smoke test 会启动临时 Halo、完成初始化、装载插件、产生访问流量、触发扫描路径告警、调用仪表盘 API,最后停止 Halo 进程并保留日志。
Console API
API 前缀:
GET /dashboard?minutes=60GET /summary?minutes=60GET /timeline?minutes=60&bucketMinutes=1GET /ips?limit=100GET /alerts?limit=100GET /blocksGET /records?ip=&path=&status=&minutes=1440&offset=0&limit=100GET /records/{id}GET /stream?minutes=60POST /alerts/{id}/acknowledgePOST /blocks/{ip}?mode=24h|7d|30d|permanent&reason=manualDELETE /blocks/{ip}DELETE /data