Allow or Deny Client IP Ranges
Let through, or block, callers according to the address they come from.
How it works
The gateway allows or refuses a request from its source address, before authentication. Use an allowlist to open an API to known networks only, or a denylist to block addresses that abuse it.
Check which address the gateway sees
Behind a CDN or a proxy, every request appears to come from the proxy. Test from the real client network before relying on a rule.
Every parameter and its default: reference.
Use cases
To open an API to your partners' addresses only, or to block an address that misbehaves.
Prerequisites
- An API instance that is deployed and answers.
Procedure
- In API Manager, go to API Instances and open the API. To cover everything published on a gateway instead, open the gateway.
- Open its Security policies and add the rule allow or block addresses.
- Choose the Default Action: Deny to let through only the addresses you list, Allow to block only those you list.
- Add Rules, in order. Each has an action (allow or deny) and one or several address ranges, such as
203.0.113.0/24. - Deploy.
Parameters
| Field | What it is | Default |
|---|---|---|
| Default Action | What happens to a caller that no rule matches. | Deny |
| Rules | In order, each with an action and address ranges. The first rule that matches decides. | — |
Verification
From an address that is not allowed
curl -i https://orders.example.com/orders
Answer
HTTP/1.1 403 Forbidden
Behavior and limits
- Rules are read in order: put the most specific first.
- The address seen is the one the gateway receives the connection from. Behind a proxy of your own, it is the address of that proxy.