skills/a6-plugin-ip-restriction/SKILL.md
Skill for configuring the Apache APISIX ip-restriction plugin via the a6 CLI. Covers IP whitelist/blacklist setup on routes, CIDR range support, IPv4/IPv6, real client IP extraction behind proxies, custom error messages, and common operational patterns.
npx skillsauth add moonming/a6 a6-plugin-ip-restrictionInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
The ip-restriction plugin controls access to routes based on client IP address.
Configure a whitelist (only listed IPs allowed) or a blacklist (listed IPs
blocked). Supports individual IPs and CIDR ranges for both IPv4 and IPv6.
| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| whitelist | array[string] | Conditional* | — | IPs/CIDR ranges allowed access |
| blacklist | array[string] | Conditional* | — | IPs/CIDR ranges denied access |
| message | string | No | "Your IP address is not allowed" | Error message (1–1024 chars) |
| response_code | integer | No | 403 | HTTP status on denial (403 or 404) |
*Constraint: Exactly one of whitelist or blacklist is required. Cannot
use both simultaneously.
192.168.1.0/24,
10.0.0.0/8, 2001:db8::/32).$remote_addr (direct client IP from the TCP
connection).a6 route create -f - <<'EOF'
{
"id": "internal-api",
"uri": "/admin/*",
"plugins": {
"ip-restriction": {
"whitelist": [
"10.0.0.0/8",
"172.16.0.0/12",
"192.168.0.0/16"
]
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"backend:8080": 1
}
}
}
EOF
# From allowed IP (e.g., 10.0.1.5) → 200 OK
curl -i http://127.0.0.1:9080/admin/dashboard
# From blocked IP → 403 Forbidden
# {"message": "Your IP address is not allowed"}
a6 route create -f - <<'EOF'
{
"id": "public-api",
"uri": "/api/*",
"plugins": {
"ip-restriction": {
"blacklist": [
"203.0.113.0/24",
"198.51.100.42"
],
"message": "Access denied from your network",
"response_code": 403
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"backend:8080": 1
}
}
}
EOF
By default, ip-restriction uses $remote_addr which is the direct client
(often a load balancer). To use the real client IP, combine with the real-ip
plugin:
{
"plugins": {
"real-ip": {
"source": "http_x_forwarded_for",
"trusted_addresses": ["10.0.0.0/8"]
},
"ip-restriction": {
"whitelist": ["203.0.113.0/24"]
}
}
}
Critical: Always set trusted_addresses in real-ip to prevent IP
spoofing. Only accept X-Forwarded-For from known proxy IPs.
{
"plugins": {
"ip-restriction": {
"blacklist": ["0.0.0.0/0"],
"whitelist": ["10.0.0.0/8"],
"response_code": 404,
"message": "Not found"
}
}
}
Note: You cannot actually use both whitelist and blacklist. Use whitelist alone to achieve the same effect — all IPs not in the whitelist are blocked.
{
"plugins": {
"ip-restriction": {
"whitelist": [
"2001:db8::/32",
"::1"
]
}
}
}
| Symptom | Cause | Fix |
|---------|-------|-----|
| Legitimate users blocked | Using $remote_addr behind proxy | Add real-ip plugin with trusted_addresses |
| All users blocked on whitelist | Client IPs not in whitelist CIDR | Verify IP ranges with curl ifconfig.me from client |
| Cannot use both whitelist and blacklist | Schema enforces oneOf | Use whitelist only (blocks all non-listed) |
| IP restriction not working after change | IP matchers are LRU-cached | Update the route config to bust cache |
version: "1"
routes:
- id: internal-api
uri: /admin/*
plugins:
ip-restriction:
whitelist:
- "10.0.0.0/8"
- "172.16.0.0/12"
upstream_id: admin-upstream
upstreams:
- id: admin-upstream
type: roundrobin
nodes:
"backend:8080": 1
tools
Core skill for working with the a6 CLI — the Apache APISIX command-line tool. Provides project conventions, command patterns, architecture overview, and development workflow. Load this skill when working on a6 source code, adding new commands, writing tests, or modifying any a6 component.
tools
Recipe skill for implementing multi-tenant API gateway patterns using the a6 CLI. Covers tenant isolation via Consumer Groups, host/path/header-based routing, per-tenant rate limiting, context forwarding with proxy-rewrite, and declarative config sync workflows for multi-tenant management.
tools
Recipe skill for configuring mutual TLS (mTLS) using the a6 CLI. Covers SSL certificate management, upstream mTLS to backend services, client certificate verification, and end-to-end mTLS setup from client through APISIX to upstream.
tools
Recipe skill for configuring upstream health checks using the a6 CLI. Covers active health checks (HTTP probing), passive health checks (response analysis), combining both, configuring healthy/unhealthy thresholds, and monitoring upstream node status.