How to block the traffic originating from few countries in APigee. We have a cloud based Apigee setup
Solved! Go to Solution.
hi @Navjot Kaur I'll start with a caveat - there is no foolproof method you can use to block traffic from specific countries. There isn't anything that maintains the true source location of a request and a fundamental issue is that it is relatively easy to disguise that true IP address, for example by using a VPN. Someone in country A makes a connection to country B via a VPN and then sends requests to country C via that VPN. Because of this, the server receiving the request in country C will have the source IP address of the server in country B. And that is just one of the ways that country-level blocks can be overcome.
That said, one thing you could to do to reduce the amount of traffic coming from unwanted locations, is utilize a geolocation service. I cannot recommend any specific providers but if you do an internet search for that term you will get a number of options to choose from.
You would extract the source IP address, then use a service callout that passes the source IP address to the geolocation service. They identify which country they believe the IP address is from and then you evaluate their response and if it's a country that you don't want to serve, your callout raises an appropriate fault and stops the request.
Hopefully other Community members will add any alternative techniques they know about. If this has helped answer your question, please click the Accept link or alternatively let us know how we can further help.