Files
2026-05-18 19:26:16 +08:00

24 lines
777 B
Markdown
Raw Permalink 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.
# ip2region 离线 IP 库
访客地理位置解析使用 [ip2region](https://github.com/lionsoul2014/ip2region) 的 `xdb` 文件。
## 获取数据文件
**`ip2region_v4.xdb`** 与 **`ip2region_v6.xdb`** 放到本目录(与本文档同级)。
访客 IP 若为 **IPv6**(如 `2403:...`),必须提供 v6 库才能显示位置。
```bash
# 在项目根目录执行(推荐脚本,一次下齐 v4+v6)
sh scripts/download-ip2region-xdb.sh
```
## 环境变量
| 变量 | 说明 |
|------|------|
| `IP2REGION_DISABLED` | `true` 时关闭解析 |
| `IP2REGION_V4_XDB` | v4 库路径(默认自动查找 `backend/data/ip2region_v4.xdb` |
| `IP2REGION_V6_XDB` | v6 库路径(可选) |
Docker 构建时会自动下载 v4 库到镜像内 `/app/data/`