After spending few sleepless nights found a workaround to do multi IP whitelisting and throttling on API manager as following.
Multi IP whitelisting and throttling is not supported by wso2 API manager pack. There are two options we have tried,
1. IP based Throttling
Go to API manager admin portal https://13.58.109.76:9444/admin/api-policy-list
throttling policies > advanced throttling > add tier
Set Request Count as the default limit
Set 1 minute as unit time
Press on add condition group > press IP condition > press "on" on IP Condition Policy
Select specific IP as IP Condition type
Add an IP address to be whitelisted and throttled
Under Execution Policy
Select Request Count as Request Count
Set Request Count as you like
Set time to 1 minute
Press on add condition group again to add the second IP and repeat the same
Add this to the API by setting it on "Advanced Throttling Policies" on API manage page on publisher page.
Pros:
No backend code changes
Can be totally managed by the end user
Cons:
No API based throttling, only IP based throttling
2. API based Throttling
Follow all the steps as above
Go to API manager carbon console > Available Execution Plans
Search for the Advanced Throttling Policy name you created
There should be 3
carbon.super_resource_ATP-nuwan_default
carbon.super_resource_ATP-nuwan_condition_125
carbon.super_resource_ATP-nuwan_condition_124
Go to carbon.super_resource_ATP-nuwan_default
copy
(((cast(map:get(propertiesMap,'ip'),'Long')==221788567l)) OR ((cast(map:get(propertiesMap,'ip'),'Long')==221932876l)))
Now go to
carbon.super_resource_ATP-nuwan_condition_124
find (cast(map:get(propertiesMap,'ip'),'Long')==22178856799l)
and replace with above
Now go to carbon.super_resource_ATP-nuwan_condition_125
delete all the code after
FROM RequestStream
Pros:
can handle API throttling instead of IP only traffic
Cons:
Required dev involvement as its a siddhi level change
If a UI change is made for the policy need to redo these changes.
Comments
Post a Comment