how to write a Custom Rate Limiting Policy in wso2 api manager(3.2.0) admin portal to block all request comes except some IP addresses to call a specific resource in rest api and also what I fill in key template section?
Asked
Active
Viewed 104 times
1 Answers
0
The easiest way is to create a Custom Mediation sequence(API Specific policy) and use something like the Throttle Mediator to block any IPs. You can add the policy per resource or for the entire API.
Update
Just observed that you are using APIM 3.2. Here is the relevant document for 3.2.0. But in 3.2.0 you can't apply the policy per resource. But in your custom mediation flow you can check the resource path and then apply the throttle mediator. For this you can use the Filter Mediator. You should be able to read the resource path with the following property.
<property name="ContextPath" expression="$axis2:REST_URL_POSTFIX" scope="axis2"/>

ycr
- 12,828
- 2
- 25
- 45
-
I want to specify that only some IP addresses can call a resource in a rest API,can you provide more detail – Ali farahzadi Feb 28 '23 at 06:16
-
1While ading a custom mediator works well as suggested by @ycr, you also need to do some capacity planning as adding custom mediation for each and every resource across all the APIs will definitely have an impact on the performance. – Joy Rathnayake Feb 28 '23 at 11:55
-
1AFAIU there is no considerable performance impact as all the mediators used are content unaware mediators. Also, you don't have to add the mediation for each and every resource. Just for the relevant APIs. – ycr Feb 28 '23 at 13:25
-
@Alifarahzadi Can you let me know which part is not clear, so I can try to explain it better? – ycr Feb 28 '23 at 13:34
-
@ycr I just read the documentation : https://apim.docs.wso2.com/en/3.2.0/learn/api-gateway/message-mediation/creating-and-uploading-using-integration-studio/ my case scenario is to allow specific IP Addresses could call APIs in resource level ,can you show me the steps of procedure using integration studio ,my another question is clarify following property:
thanx – Ali farahzadi Feb 28 '23 at 13:58 -
1@Alifarahzadi I would suggest downloading an existing policy from the Publisher and trying to alter it and reuploading it, You don't really need the integration Studio. Feel free to create SO questions as you need assistance. – ycr Mar 01 '23 at 00:45