
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
https://github.com/observabilitystack/geoip-api/actions/workflows/ci.yaml/badge.svg?branch=master](https://github.com/observabilitystack/geoip-api/actions/workflows/ci.yaml) https://img.shields.io/docker/pulls/observabilitystack/geoip-api](https://hub.docker.com/r/observabilitystack/geoip-api) !https://img.shields.io/github/release-date/observabilitystack/geoip-api !https://img.shields.io/github/last-commit/observabilitystack/geoip-api !https://img.shields.io/github/license/observabilitystack/geoip-api
♻️ 这是https://github.com/shopping24%E5%8E%9F%E5%A7%8B%E4%BB%93%E5%BA%93%E7%9A%84%E5%AE%98%E6%96%B9%E7%BB%B4%E6%8A%A4%E5%88%86%E6%94%AF%EF%BC%8C%E7%94%B1@tboeghk%E7%BB%B4%E6%8A%A4%E3%80%82
本项目提供一个简单的REST Web服务,用于返回给定IP地址的地理位置信息。该服务从https://dev.maxmind.com/geoip/geoip2/geolite2/%EF%BC%88%E5%85%8D%E8%B4%B9%EF%BC%89%E6%88%96GeoIP2 City(商业)数据库加载位置信息。
您可以在微服务架构中使用此项目,当多个服务需要请求地理位置数据时尤为适用。该服务可与https://www.elastic.co/guide/en/logstash/current/plugins-filters-http.html%E9%85%8D%E5%90%88%E4%BD%BF%E7%94%A8%EF%BC%8C%E4%BB%A5%E4%B8%B0%E5%AF%8C%E6%97%A5%E5%BF%97%E6%95%B0%E6%8D%AE%E3%80%82
Docker Hub上提供的Docker镜像捆绑了最新的https://dev.maxmind.com/geoip/geoip2/geolite2/%E3%80%82%E5%AE%B9%E5%99%A8%E6%AF%8F%E5%91%A8%E6%9E%84%E5%BB%BA%E4%B8%80%E6%AC%A1%EF%BC%8C%E5%8C%85%E5%90%AB%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC%E7%9A%84%E6%95%B0%E6%8D%AE%E5%BA%93%E3%80%82
$ docker run -p 8080:8080 ghcr.io/observabilitystack/geoip-api:latest
$ docker run -p 8080:8080 observabilitystack/geoip-api:latest
💡 尽管在生产环境中不推荐使用
latest标签运行容器,但对于geoip-api,我们强烈建议使用latest以获取最新的地理位置数据。
yyyy-VV(年份和周数)。latest。amd64和arm64架构。☝️ 在生产环境中,强烈建议使用商业版https://www.maxmind.com/en/geoip2-city%EF%BC%8C%E5%9B%A0%E5%85%B6%E5%85%B7%E6%9C%89%E6%9B%B4%E9%AB%98%E7%9A%84%E7%B2%BE%E5%BA%A6%E5%92%8C%E6%95%B0%E6%8D%AE%E8%B4%A8%E9%87%8F%E3%80%82
您可以将mmdb格式的数据库挂载到容器中。数据库位置可通过以下变量自定义:
| 变量名 | 描述 | 默认值 |
|---|---|---|
| CITY_DB_FILE | GeoIP2 City或GeoLite2数据库文件路径 | /srv/GeoLite2-City.mmdb |
| ASN_DB_FILE | GeoIP2 ASN数据库文件路径 | /srv/GeoLite2-ASN.mmdb |
| ISP_DB_FILE | GeoIP2 ISP数据库文件路径 | (无) |
examples文件夹包含在Docker-Compose或Kubernetes中运行geoip-api的示例。
查询API的推荐方式是通过简单的HTTP GET请求。将待解析的IP地址作为路径参数提供。
bash$ curl -s http://localhost:8080/8.8.8.8 { "country": "US", "latitude": "37.751", "longitude": "-97.822", "continent": "NA", "timezone": "America/Chicago", "accuracyRadius": 1000, "asn": 15169, "asnOrganization": "GOOGLE", "asnNetwork": "8.8.8.0/24" } $ curl -s "http://localhost:8080/$(curl -s https://ifconfig.me/ip)" { "country": "DE", "stateprov": "Free and Hanseatic City of Hamburg", "stateprovCode": "HH", "city": "Hamburg", "latitude": "53.5742", "longitude": "10.0497", "continent": "EU", "timezone": "Europe/Berlin", "asn": 15943, "asnOrganization": "wilhelm.tel GmbH" }
Geoip-API在Link头中返回指向详细滥用和RIPE信息的链接。ripe-asn信息可直接获取。abuse链接需要注册并获取API密钥才能访问。
bashcurl "http://localhost:8080/$(curl -s https://ifconfig.me/ip)" HTTP/1.1 200 Link: <https://api.abuseipdb.com/api/v2/check?ipAddress=104.151.58.228>; rel="abuse", <https://stat.ripe.net/data/as-overview/data.json?resource=8881>; rel="ripe-asn" { "country": "DE", "stateprov": "Land Berlin", "stateprovCode": "BE", "city": "Berlin", "latitude": "52.5196", "longitude": "13.4069", "continent": "EU", "timezone": "Europe/Berlin", "accuracyRadius": 200, "asn": 8881, "asnOrganization": "1&1 Versatel Deutschland GmbH", "asnNetwork": "104.151.0.0/17" }
X-Geoip-Address头是查询API的另一种方式(如Nginx-Geoip示例中使用)。在此方式中,待解析的地址作为头值提供,地理位置信息也通过头值返回,返回码始终为204。
bash$ curl -sI -H "X-Geoip-Address: $(curl -s https://ifconfig.me/ip)" "http://localhost:8080/" HTTP/1.1 204 X-Geoip-Country: DE X-Geoip-StateProv: Free and Hanseatic City of Hamburg X-Geoip-City: Hamburg X-Geoip-Latitude: 53.6042 X-Geoip-Longitude: 10.0596 X-Geoip-Continent: EU X-Geoip-Timezone: Europe/Berlin
bashcurl --location 'http://localhost:8080/' \ --header 'Content-Type: application/json' \ --data '[ "8.8.8.8", "8.8.4.4" ]' { "8.8.4.4": { "country":"US", "latitude":"37.751", "longitude":"-97.822", "continent":"NA", "timezone":"America/Chicago", "accuracyRadius":1000, "asn":15169, "asnOrganization":"GOOGLE", "asnNetwork":"8.8.4.0/24" }, "8.8.8.8": { "country":"US", "latitude":"37.751", "longitude":"-97.822", "continent":"NA", "timezone":"America/Chicago", "accuracyRadius":1000, "asn":15169, "asnOrganization":"GOOGLE", "asnNetwork":"8.8.8.0/24" } }
一次最多支持100个地址。
结果为JSON对象,按请求的IP地址索引。
若请求的地址无法解析,响应中将缺少该条目。
项目通过多阶段Docker构建。需要有效的Maxmind许可证密钥以下载Geoip2数据库。
shell$ export MAXMIND_LICENSE_KEY=... $ docker build \ --build-arg MAXMIND_LICENSE_KEY=${MAXMIND_LICENSE_KEY} \ --build-arg VERSION=$(date +%Y-%V) \ -t geoip-api:latest .
若要构建(或测试)多平台镜像,使用https://docs.docker.com/buildx/working-with-buildx/%EF%BC%9A
shell$ docker buildx create --use --name multi-platform $ docker buildx build \ --platform linux/amd64,linux/arm64 \ --build-arg MAXMIND_LICENSE_KEY=${MAXMIND_LICENSE_KEY} \ -t geoip-api:latest-native -f Dockerfile.native .
我们期待您的评论、问题和拉取请求!
本项目采用http://www.apache.org/licenses/LICENSE-2.0.html%E8%AE%B8%E5%8F%AF%E8%AF%81%E3%80%82
本产品包含MaxMind创建的GeoLite2数据,可从[***]
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务