A lightweight internal proxy service that wraps Baidu IP portrait API.
52
A lightweight internal proxy service that wraps Baidu IP portrait API behind a clean, self-hosted HTTP endpoint. Built with FastAPI + pycurl on Python 3.14 Alpine, using a persistent curl handle for TCP/TLS session reuse.
⚠️ For internal / private use only. This image proxies a third-party, non-public API. Evaluate the upstream provider's Terms of Service before using it in any commercial or public-facing environment.
GET /query?ip=<ip> → raw JSON from upstreampycurl.Curl handle, with
background keep-alive requests every 30s to maintain the TLS sessionapplication/json; charset=utf-8,
no garbled Chinese outputAsia/Shanghai preconfigureddocker run -d \
--name briefinfo \
-p 18000:18000 \
--restart unless-stopped \
gitree/briefinfo:beta
Then:
curl "http://127.0.0.1:18000/query?ip=8.8.8.8"
GET /queryQuery the IP portrait / geo information for a given IPv4 or IPv6 address.
| Parameter | Type | Required | Description |
|---|---|---|---|
ip | string | yes | IPv4 or IPv6 address |
Example
curl "http://127.0.0.1:18000/query?ip=8.8.8.8"
Response
200 OK — raw JSON body from upstream, Content-Type: application/json; charset=utf-8Interactive docs (FastAPI built-in):
http://127.0.0.1:18000/docs
| Env var | Default | Description |
|---|---|---|
TZ | Asia/Shanghai | Container timezone |
The upstream URL and request headers are currently compiled into the image.
To change them, rebuild with a modified main.py.
services:
ip-api:
image: <your-dockerhub-username>/ip-api:latest
container_name: ip-api
restart: unless-stopped
ports:
- "127.0.0.1:18000:18000" # bind to loopback; expose via reverse proxy
environment:
- TZ=Asia/Shanghai
mem_limit: 256m
cpus: 1.0
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
healthcheck:
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:18000/query?ip=8.8.8.8"]
interval: 30s
timeout: 5s
retries: 3
cachetools.TTLCache) if you need more.main.py.appuser (UID 1000)No license declared. Third-party API usage is the operator's responsibility.
Content type
Image
Digest
sha256:e76459b7d…
Size
48.2 MB
Last updated
7 days ago
docker pull gitree/briefinfo:beta