Parameters

Parameter

Type

Required

Default Value

Description

Rules

nameStringYes-Policy name

API must be unique in Proxy

descriptionStringNo-Policy description-
activeBooleanNotrueWhether the policy is active-
targetVariableForIPVariableDTONo-The variable from which to get the IP address. If this value is not specified, Apinizer's default IP retrieval method will be used.
ipListList<String>Yes[ ]

List of IP addresses to be blocked.

The characters ('*' and '-') can be used to specify an IP range. For example

  • The value '10.3.10.*' refers to IPs between '10.3.10.0' and '10.3.10.255'.
  • The value '10.3.10.4-18' refers to IPs between '10.3.10.4' and '10.3.10.18' (including 4 and 18).
Must contain at least one IP address

1. Simple IP Blocking

{
  "operationMetadata" : {
    "targetScope" : "ALL",
    "targetPipeline" : "REQUEST",
    "deploy" : true,
    "deployTargetEnvironmentNameList": [
      "test", "prod"
    ],
    "order" : 1
  },
  "policy" : {
    "type" : "policy-black-ip",
    "name" : "BasicIpBlocking",
    "description" : "Block specific IP addresses",
    "ipList" : [ "192.168.1.100", "10.0.0.50"  ]
  }
}


2. IP Blocking with Custom Variable

{
  "operationMetadata" : {
    "targetScope" : "ENDPOINT",
    "targetEndpoint" : "/api/v1/secure",
    "targetEndpointHTTPMethod" : "POST",
    "targetPipeline" : "REQUEST",
    "deploy" : true,
    "deployTargetEnvironmentNameList": [
      "test", "prod"
    ],
    "order" : 1
  },
  "policy" : {
    "type" : "policy-black-ip",
    "name" : "PrivateVariableIpBlocking",
    "description" : "Get and block IP from X-Forwarded-For header",
    "ipList" : [ "192.168.1.0-255", "10.0.*.*" ],
    "targetVariableForIP" : {
      "name" : "clientIp",
      "type" : "HEADER",
      "headerName" : "X-Forwarded-For",
      "description" : "Real IP behind Load Balancer"
    }
  }
}