
Intro #
Traefik is a modern application proxy and reverse proxy commonly used to route HTTP and HTTPS traffic to applications running in Docker, Kubernetes, and other environments. Traefik GeoIP can add IP geolocation and network information to incoming requests, allowing backend applications to identify a visitor’s country, region, city, and ASN without making an external API request.
In this tutorial, we will configure Traefik on a Debian 13 server to perform local IP geolocation using the free IP2Location LITE databases in MMDB format.
We will use:
- IP2Location LITE DB11 MMDB for country, region, city, latitude, longitude, ZIP/postal code, and time zone information.
- IP2Location LITE ASN MMDB for Autonomous System Number (ASN) and Autonomous System information.
IP2Location LITE DB11 already contains country information, so a separate DB1 Country database is not required. IP2Location currently provides both DB11 and ASN databases in MMDB format.
The completed setup will look like this:

The GeoIP lookup happens locally on the Debian server. No external IP geolocation API request is required for each incoming HTTP request.
About the Traefik GeoIP plugin #
The original traefikgeoip2 plugin was designed to use GeoIP2/GeoLite2-compatible MMDB databases.
For this tutorial, we will use the newer thiagotognoli/traefikgeoip plugin. It is a fork of the original traefikgeoip2 project and supports separate City, Country, and ASN MMDB database paths.
The plugin supports the following database settings:
cityDbPath
countryDbPath
asnDbPath
Because IP2Location LITE DB11 already contains country-level information, this tutorial only needs:
cityDbPath
asnDbPath
The plugin’s code also explicitly supports using a City database together with an ASN database.
For this tutorial, we will use:
Operating system: Debian 13
Container runtime: Docker Engine
Configuration: Docker Compose
Reverse proxy: Traefik 3.7
GeoIP plugin: github.com/thiagotognoli/traefikgeoip
Demo backend: traefik/whoami
GeoIP database: IP2Location LITE DB11 MMDB
ASN database: IP2Location LITE ASN MMDB
You will also need an IP2Location account to download the LITE databases.
Step 1: Update Debian #
Update the package list:
sudo apt update
Install the utilities required for this tutorial:
sudo apt install -y ca-certificates curl unzip
Step 2: Install Docker Engine #
First, create the directory for Docker’s repository signing key:
sudo install -m 0755 -d /etc/apt/keyrings
Download Docker’s official signing key:
sudo install -m 0755 -d /etc/apt/keyringssudo curl -fsSL https://download.docker.com/linux/debian/gpg \
 -o /etc/apt/keyrings/docker.asc
Make the key readable:
sudo chmod a+r /etc/apt/keyrings/docker.asc
Add Docker’s official Debian repository:
sudo tee /etc/apt/sources.list.d/docker.sources > /dev/null <<EOF
Types: deb
URIs: https://download.docker.com/linux/debian
Suites: $(. /etc/os-release && echo "$VERSION_CODENAME")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
Update the package list again:
sudo apt update
Install Docker Engine, Docker CLI, containerd, Buildx, and Docker Compose:
sudo apt install -y \
 docker-ce \
 docker-ce-cli \
 containerd.io \
 docker-buildx-plugin \
 docker-compose-plugin
Docker’s official Debian installation instructions use this repository-based installation method and currently list Debian 13 as supported.
Verify that Docker is running:
sudo systemctl status docker

You can also run Docker’s test container:
sudo docker run hello-world
If the installation is working correctly, Docker will download the hello-world image and display a confirmation message.

Step 3: Create the project directory #
Create a directory for the Traefik demonstration:
mkdir -p ~/traefik-ip2location/geoip
The final directory structure will look like this:

Step 4: Download the required MMDB files #
Sign in to your IP2Location account and copy your download token which we’ll use to download the required files.
Run the code below to download (replace YOUR_DOWNLOAD_TOKEN with the actual one):
TOKEN="YOUR_DOWNLOAD_TOKEN"
curl -L -o DB11.zip "https://www.ip2location.com/download?token=${TOKEN}&file=DB11LITEMMDB"
curl -L -o ASN.zip "https://www.ip2location.com/download?token=${TOKEN}&file=DBASNLITEMMDB"
After downloading the ZIP archives to your home folder, move them into the GeoIP directory.
mv ~/DB11.zip \
 ~/traefik-ip2location/geoip/
mv ~/ASN.zip \
 ~/traefik-ip2location/geoip/
Change into the GeoIP directory:
cd ~/traefik-ip2location/geoip
Check the downloaded files:
ls -lh
Extract the DB11 MMDB:
unzip DB11.zip IP2LOCATION-LITE-DB11.MMDB
Extract the ASN MMDB:
unzip ASN.zip IP2LOCATION-LITE-ASN.MMDB
Check the contents again:
ls -lh
You should have the below MMDB files:
IP2LOCATION-LITE-DB11.MMDB
IP2LOCATION-LITE-ASN.MMDB

If the downloaded filenames differ slightly, rename them for consistency.
For example:
mv <DB11-MMDB-FILENAME> IP2LOCATION-LITE-DB11.MMDB
And:
mv <ASN-MMDB-FILENAME> IP2LOCATION-LITE-ASN.MMDB
Set normal read permissions:
chmod 644 *.MMDB
Return to the project directory:
cd ~/traefik-ip2location
Step 5: Create the Docker Compose configuration #
Create the Compose file:
nano docker-compose.yml
Add the following configuration:
services:
traefik:
image: traefik:v3.7
container_name: traefik
restart: unless-stopped
command:
- "--api.insecure=true"
- "--log.level=INFO"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--experimental.plugins.traefikgeoip.modulename=github.com/thiagotognoli/traefikgeoip"
- "--experimental.plugins.traefikgeoip.version=v1.1.1"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./geoip:/usr/share/GeoIP:ro"
whoami:
image: traefik/whoami
container_name: whoami
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=PathPrefix(`/`)"
- "traefik.http.routers.whoami.entrypoints=web"
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.cityDbPath=/usr/share/GeoIP/IP2LOCATION-LITE-DB11.MMDB"
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.asnDbPath=/usr/share/GeoIP/IP2LOCATION-LITE-ASN.MMDB"
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.ipHeader=X-IP"
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.debug=true"
- "traefik.http.routers.whoami.middlewares=traefikgeoip"
Save the file.
The plugin must first be declared in Traefik’s static configuration using its module name and version. Traefik’s plugin documentation requires both moduleName and version when loading a published plugin.
The current Traefik Plugin Catalog lists:
github.com/thiagotognoli/traefikgeoip
with version:
v1.1.1
Step 6: Understand the MMDB configuration #
These two labels are the important part of the GeoIP database configuration:
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.cityDbPath=/usr/share/GeoIP/IP2LOCATION-LITE-DB11.MMDB"
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.asnDbPath=/usr/share/GeoIP/IP2LOCATION-LITE-ASN.MMDB"
The first line tells the plugin to use IP2Location LITE DB11 as its City-compatible MMDB database.
The second tells it to use the IP2Location LITE ASN MMDB database for ASN lookups.
The plugin explicitly provides both cityDbPath and asnDbPath configuration parameters.
Notice that there is no countryDbPath:
cityDbPath -> IP2Location LITE DB11
asnDbPath -> IP2Location LITE ASN
That is intentional.
DB11 already contains:
Country
Region
City
Latitude
Longitude
ZIP code
Time zone
so, loading a separate DB1 Country database would duplicate information already available from DB11.
Step 7: Understand the Docker volume #
The following line mounts our local database directory into the Traefik container:
- "./geoip:/usr/share/GeoIP:ro"
On the Debian host, the files are located at:
~/traefik-ip2location/geoip/
Inside the Traefik container, they appear as:
/usr/share/GeoIP/
Therefore:
Host:
~/traefik-ip2location/geoip/IP2LOCATION-LITE-DB11.MMDB
becomes:
Container:
/usr/share/GeoIP/IP2LOCATION-LITE-DB11.MMDB
The :ro option mounts the directory as read-only because Traefik only needs to read the databases.
Step 8: Why we use the X-IP header for testing #
The plugin normally determines which IP address to look up from the incoming connection.
However, when testing from the same Debian server, Traefik may see an address such as:
127.0.0.1
or an internal Docker address such as:
172.18.0.1
Those are private addresses and do not have normal public IP geolocation records.
To make the demonstration reproducible, we configured:
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.ipHeader=X-IP"
The plugin supports ipHeader as an alternate header from which the lookup IP can be obtained.
This means we can test any public IP address using:
X-IP: 8.8.8.8
without changing the real TCP connection.
This setting is particularly useful for a tutorial because everyone can test the same IP address.
Step 9: Validate the Docker Compose file #
Before starting the containers, validate the configuration:
sudo docker compose config
If the YAML is valid, Docker Compose will output the resolved configuration.
Step 10: Start Traefik #
Start Traefik and the whoami backend:
sudo docker compose up -d

Check the running containers:
sudo docker compose ps
You should see something similar to:

Step 11: Check that the plugin loaded #
Check the Traefik logs:
sudo docker logs traefik
To look specifically for plugin-related messages:
sudo docker logs traefik 2>&1 | grep -i plugin

You can also look for GeoIP-related messages:
sudo docker logs traefik 2>&1 | grep -i geoip
Traefik downloads published plugins according to the module name and version configured under experimental.plugins.
Step 12: Verify that Traefik can see the MMDB files #
List the database directory from inside the running Traefik container:
sudo docker exec traefik ls -lh /usr/share/GeoIP
You should see:
IP2LOCATION-LITE-DB11.MMDB
IP2LOCATION-LITE-ASN.MMDB

If both files appear, the volume mount is working correctly.
Step 13: Test the backend without GeoIP first #
The traefik/whoami container is a very small HTTP service that displays information about the HTTP request it receives.
Test it through Traefik:
curl http://127.0.0.1/
You should receive output containing information such as:

This confirms that:

is working correctly.
Step 14: Test an IP2Location lookup #
Now send the same request but add a public IP address using the X-IP header.
For example:
curl -H "X-IP: 8.8.8.8" http://127.0.0.1/
The request flow is now:

Because whoami displays the incoming request headers, you can see the GeoIP information inserted by the middleware before the request reaches the application.
For easier inspection, filter the output:
curl -s \
 -H "X-IP: 8.8.8.8" \
 http://127.0.0.1/ \
 | grep -i geo

You can also search for ASN-related information:
curl -s \
 -H "X-IP: 8.8.8.8" \
 http://127.0.0.1/ \
 | grep -i asn

Or simply inspect the complete response:
curl -s \
 -H "X-IP: 8.8.8.8" \
 http://127.0.0.1/

The exact geographic values can change over time as IP allocations and geolocation information are updated.
Step 15: Test another IP address #
Try another public address:
curl -H "X-IP: 1.1.1.1" http://127.0.0.1/
Or:
curl -s \
 -H "X-IP: 1.1.1.1" \
 http://127.0.0.1/ \
 | grep -i -E "geo|asn"
You can substitute any public IPv4 or IPv6 address that exists in the database.
For example:
curl -H "X-IP: 9.9.9.9" http://127.0.0.1/
Each lookup is performed against the local MMDB files.
No IP2Location API request is made.
Step 16: View the Traefik dashboard #
For demonstration purposes, we enabled Traefik’s insecure API/dashboard using:
"--api.insecure=true"
Open:
http://SERVER_IP:8080/
Or, from the Debian server itself:
http://127.0.0.1:8080/

The dashboard lets you inspect:
HTTP routers
Services
Middleware
Entry points
You should be able to see the traefikgeoip middleware attached to the whoami router.
The insecure dashboard should only be used for testing.
Do not expose port 8080 directly to the Internet in a production environment.
Step 17: Use the real visitor IP in production #
The X-IP setting was useful for testing, but you normally do not want Internet users to decide which IP Traefik looks up.
For a real deployment, remove this line:
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.ipHeader=X-IP"
Then apply the updated configuration:
sudo docker compose up -d
Traefik will then allow the plugin to use the address associated with the incoming connection.
Using X-Forwarded-For behind another proxy #
If Traefik runs behind another trusted reverse proxy, CDN, or load balancer, the actual visitor IP may instead be supplied through:
X-Forwarded-For
The plugin provides the option:
preferXForwardedForHeader
It can be enabled with:
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.preferXForwardedForHeader=true"
The request flow could then look like:

Only enable this when Traefik is behind infrastructure that you trust.
A client connecting directly to Traefik can potentially supply its own X-Forwarded-For header, so forwarded-header trust must be configured carefully in production.
How IP2Location LITE DB11 is used #
The cityDbPath configuration points to:
IP2LOCATION-LITE-DB11.MMDB
DB11 provides:
Country Code
Country Name
Region / State
City
Latitude
Longitude
ZIP / Postal Code
Time Zone
IP2Location describes LITE DB11 as translating an IP address into country, region, city, latitude, longitude, ZIP code, and time zone information.
The configuration is:
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.cityDbPath=/usr/share/GeoIP/IP2LOCATION-LITE-DB11.MMDB"
Because country information is already included in DB11, there is no need to additionally configure DB1.
How IP2Location LITE ASN is used #
The second database is:
IP2LOCATION-LITE-ASN.MMDB
It provides:
ASN
Autonomous System name
IP2Location describes the LITE ASN database as translating an IP address into an Autonomous System and Autonomous System Number.
It is configured using:
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.asnDbPath=/usr/share/GeoIP/IP2LOCATION-LITE-ASN.MMDB"
The plugin can load a City database and ASN database at the same time. Its middleware implementation contains a dedicated City-plus-ASN lookup path.
Why use MMDB files locally? #
Using local MMDB databases has several advantages.
No GeoIP API request for every connection #
The lookup happens locally:

There is no additional request such as:

for each visitor.
Lower lookup latency #
The database is available locally to the middleware, avoiding the network latency of an external API call.
No per-request API quota #
Because Traefik reads a local database, normal GeoIP lookups do not consume API requests.
Visitor IP information stays on the server #
The visitor’s IP does not need to be sent to another web service simply to determine its geographical or ASN information.
Updating the IP2Location databases #
IP allocations change over time, so the MMDB files should be updated regularly.
For example, the IP2Location LITE DB11 database is published with regular database updates.
After downloading newer versions, replace:
IP2LOCATION-LITE-DB11.MMDB
IP2LOCATION-LITE-ASN.MMDB
inside:
~/traefik-ip2location/geoip/
Then restart Traefik:
cd ~/traefik-ip2location
sudo docker compose restart traefik
This ensures that the middleware reopens the updated MMDB files.
Troubleshooting #
Traefik does not start #
Check the container state:
sudo docker compose ps
Then inspect the Traefik log:
sudo docker logs traefik
For plugin-specific errors:
sudo docker logs traefik 2>&1 | grep -i plugin
GeoIP middleware does not appear #
Confirm that these two static configuration parameters are present:
--experimental.plugins.traefikgeoip.modulename=github.com/thiagotognoli/traefikgeoip
--experimental.plugins.traefikgeoip.version=v1.1.1
Traefik requires the plugin module name and version to be declared in the static configuration before the middleware can use it.
Restart Traefik after modifying the configuration:
sudo docker compose restart traefik
Traefik cannot find the MMDB database #
Verify the files on the Debian host:
ls -lh ~/traefik-ip2location/geoip/
You should see:
IP2LOCATION-LITE-DB11.MMDB
IP2LOCATION-LITE-ASN.MMDB
Then check the files from inside the Traefik container:
sudo docker exec traefik ls -lh /usr/share/GeoIP/
If the files do not appear inside the container, check this volume configuration:
- "./geoip:/usr/share/GeoIP:ro"
Permission denied when opening an MMDB file #
Check the permissions:
ls -l ~/traefik-ip2location/geoip/*.MMDB
Set the files as readable:
chmod 644 ~/traefik-ip2location/geoip/*.MMDB
Restart Traefik:
sudo docker compose restart traefik
No result when looking up localhost #
If you test:
127.0.0.1
you should not expect normal geographic information.
The same applies to private network ranges such as:
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16
Use a public IP for the demonstration:
curl -H "X-IP: 8.8.8.8" http://127.0.0.1/
Check Traefik debug information #
We enabled plugin debugging using:
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.debug=true"
The plugin exposes debug as a supported configuration option.
Check the logs with:
sudo docker logs traefik
For a production deployment, you can remove or disable debugging once everything is working.
Stop the demonstration #
To stop and remove the containers:
cd ~/traefik-ip2location
sudo docker compose down
To start them again:
sudo docker compose up -d
Complete Docker Compose configuration #
For reference, the complete configuration used in this tutorial is:
services:
traefik:
image: traefik:v3.7
container_name: traefik
restart: unless-stopped
command:
- "--api.insecure=true"
- "--log.level=INFO"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--experimental.plugins.traefikgeoip.modulename=github.com/thiagotognoli/traefikgeoip"
- "--experimental.plugins.traefikgeoip.version=v1.1.1"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./geoip:/usr/share/GeoIP:ro"
whoami:
image: traefik/whoami
container_name: whoami
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=PathPrefix(`/`)"
- "traefik.http.routers.whoami.entrypoints=web"
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.cityDbPath=/usr/share/GeoIP/IP2LOCATION-LITE-DB11.MMDB"
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.asnDbPath=/usr/share/GeoIP/IP2LOCATION-LITE-ASN.MMDB"
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.ipHeader=X-IP"
- "traefik.http.middlewares.traefikgeoip.plugin.traefikgeoip.debug=true"
- "traefik.http.routers.whoami.middlewares=traefikgeoip"
Conclusion #
In this tutorial, we configured Traefik on Debian 13 to perform local IP geolocation using two IP2Location LITE databases:

The resulting request flow is:

Because IP2Location LITE DB11 already includes country information, a separate DB1 MMDB database is unnecessary for this configuration.
The GeoIP middleware performs the lookup locally using the MMDB files, making the geographical and ASN information available to applications behind Traefik without requiring an external IP geolocation API request for each visitor.
