> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Geographic Access Control Using Geolocation in Apinizer

> Blocking or allowing requests from specific cities using the geolocation feature

This document explains how to **block** or **allow** requests from specific cities using the **geolocation** (geographic location) feature on the Apinizer platform.

At the end of the work, we will display which cities these incoming requests come from through **Kibana Map**.

## 1) Providing Geolocation Data

To provide this data, you can use services such as [MaxMind](https://www.maxmind.com/), [IpGeolocation](http://ipgeolocation.io). These services allow you to download databases containing IP and city information.

In this step, we will explain how to use the free **GeoLite2 City** **database** offered by **MaxMind** by downloading it.

Apinizer usually uses the 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, extract it, and obtain our .mmdb extension file:

<img src="https://mintcdn.com/apinizer/ZL12cDVBToJY2EPV/images/tutorials/nasil-yapilir-kilavuzlari/yonetici-kilavuzlari/geolocation-erisim-kontrolu/01-maxmind-download.png?fit=max&auto=format&n=ZL12cDVBToJY2EPV&q=85&s=93487092bc2225ecd76934628fffb6be" alt="MaxMind GeoLite2 City Database Download" width="1000" data-path="images/tutorials/nasil-yapilir-kilavuzlari/yonetici-kilavuzlari/geolocation-erisim-kontrolu/01-maxmind-download.png" />

## 2) Integration of Geolocation Database into Apinizer

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

<img src="https://mintcdn.com/apinizer/ZL12cDVBToJY2EPV/images/tutorials/nasil-yapilir-kilavuzlari/yonetici-kilavuzlari/geolocation-erisim-kontrolu/02-geolocation-settings.png?fit=max&auto=format&n=ZL12cDVBToJY2EPV&q=85&s=69547cc43b55aeb0482e8f285cd8c959" alt="IP Geolocation Setting Page" width="1000" data-path="images/tutorials/nasil-yapilir-kilavuzlari/yonetici-kilavuzlari/geolocation-erisim-kontrolu/02-geolocation-settings.png" />

## 3) Enabling XFF and Adding Allowed/Blocked IP List Policy

Through Apinizer, the real **IP** address of the **client** in requests can be **determined** using the **X-Forwarded-For (XFF)** header information.

With the **Allowed IP** policy, requests from specific IP addresses or specific cities can be **allowed**. Using the **Blocked IP** policy, these requests can be **blocked**.

To use XFF information, you can enable it from the Settings tab in Proxy settings:

<img src="https://mintcdn.com/apinizer/ZL12cDVBToJY2EPV/images/tutorials/nasil-yapilir-kilavuzlari/yonetici-kilavuzlari/geolocation-erisim-kontrolu/03-xff-settings.png?fit=max&auto=format&n=ZL12cDVBToJY2EPV&q=85&s=4b33a1a393fd6c7dd9b90bb18172cdff" alt="X-Forwarded-For Enablement" width="1000" data-path="images/tutorials/nasil-yapilir-kilavuzlari/yonetici-kilavuzlari/geolocation-erisim-kontrolu/03-xff-settings.png" />

Let's block requests coming from Istanbul by adding the Blocked IP List policy to this Proxy:

<img src="https://mintcdn.com/apinizer/ZL12cDVBToJY2EPV/images/tutorials/nasil-yapilir-kilavuzlari/yonetici-kilavuzlari/geolocation-erisim-kontrolu/04-blocked-ip-policy.png?fit=max&auto=format&n=ZL12cDVBToJY2EPV&q=85&s=0428b1298c5fc5e7a56b960b5a660aaf" alt="Blocked IP List Policy" width="1000" data-path="images/tutorials/nasil-yapilir-kilavuzlari/yonetici-kilavuzlari/geolocation-erisim-kontrolu/04-blocked-ip-policy.png" />

Istanbul is selected from the IP Geolocation field and saved:

<img src="https://mintcdn.com/apinizer/ZL12cDVBToJY2EPV/images/tutorials/nasil-yapilir-kilavuzlari/yonetici-kilavuzlari/geolocation-erisim-kontrolu/05-istanbul-selection.png?fit=max&auto=format&n=ZL12cDVBToJY2EPV&q=85&s=b77890ef6210485b5760c0d9b45721ef" alt="Istanbul City Selection" width="1000" data-path="images/tutorials/nasil-yapilir-kilavuzlari/yonetici-kilavuzlari/geolocation-erisim-kontrolu/05-istanbul-selection.png" />

## 4) Access Blocking and Result

Access was blocked in a request made to the service with an IP address from Istanbul location:

<img src="https://mintcdn.com/apinizer/cyfybFLapH5lQSK7/images/tutorials/nasil-yapilir-kilavuzlari/yonetici-kilavuzlari/geolocation-erisim-kontrolu/06-access-blocked.png?fit=max&auto=format&n=cyfybFLapH5lQSK7&q=85&s=7fb2b6acc36af1c1c2cc62dd457be2ed" alt="Access Blocked" width="1000" data-path="images/tutorials/nasil-yapilir-kilavuzlari/yonetici-kilavuzlari/geolocation-erisim-kontrolu/06-access-blocked.png" />

## Summary

1. We explained how to block requests coming from Istanbul on the Apinizer platform.
2. We downloaded the GeoLite2 City database offered by MaxMind and integrated this data into Apinizer.
3. We controlled requests from specific cities by determining the real IP addresses of clients using 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.

<Warning>
  To visualize which cities incoming requests come from on Kibana, see the [Geographic Visualization with Kibana Maps](/en/operations/administrator-guides/kibana-maps-geographic-visualization) documentation.
</Warning>
