Skip to main content
This document explains how to block or allow requests coming from specific cities using geolocation (geographic location) feature on Apinizer platform. At the end of the work, we will display on Kibana Map to visualize which cities these incoming requests come from.

1) Providing Geolocation Data

To provide this data, you can benefit from MaxMind, IpGeolocation services. These services allow you to download databases containing IP and city information. In this step, we will explain how to use it by downloading the free GeoLite2 City database offered by MaxMind. Apinizer usually uses client IP address to obtain geolocation data. The incoming IP address is queried through a database to determine which city the request comes from. After completing the registration process on the page, we go to the red marked area specified below and download the zip file in the GeoLite2 City section and extract it to obtain our .mmdb extension file: MaxMind GeoLite2 City Download

2) Integration of Geolocation Database to Apinizer

.mmdb extension file is added here and deployed from Administration → System Settings → IP Geolocation Setting page. IP Geolocation Setting

3) Activating XFF and Adding Allowed/Blocked IP List Policy

Through Apinizer, the real IP address of the client can be determined in requests using X-Forwarded-For (XFF) header information. With Allowed IP policy, permission can be given to requests coming from specific IP addresses or specific cities. Using Blocked IP policy, these requests can be blocked. To use XFF information, you can activate it from Settings tab through Proxy settings: XFF Activation Let’s block requests coming from Istanbul by adding Blocked IP List policy to this Proxy: Blocked IP List Policy Istanbul is selected from IP Geolocation field and saved: IP Geolocation Istanbul Selection

4) Access Blocking and Result

Access was blocked in a request made to the service with an IP address from Istanbul location: Access Blocked
  1. We explained how we blocked requests coming from Istanbul on Apinizer platform.
  2. We downloaded the GeoLite2 City database offered by MaxMind and integrated this data into Apinizer.
  3. We controlled requests coming from specific cities by determining the real IP addresses of clients with X-Forwarded-For (XFF) header information.
  4. We selected Istanbul using Block Ip List policies to block requests coming from Istanbul and successfully blocked access from this city.
Very ImportantTo visualize which cities incoming requests come from on Kibana, you can check the Geographic Visualization with Kibana Maps page.