Skip to content

Commit 4ea4c2b

Browse files
Merge pull request #22 from txwgnd/main
Add GeoLite2 automation community guide
2 parents 19dea14 + a02e360 commit 4ea4c2b

File tree

7 files changed

+118
-1
lines changed

7 files changed

+118
-1
lines changed

docs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@
140140
"self-host/community-guides/metrics",
141141
"self-host/community-guides/homeassistant",
142142
"self-host/community-guides/middlewaremanager",
143-
"self-host/community-guides/traefiklogsdashboard"
143+
"self-host/community-guides/traefiklogsdashboard",
144+
"self-host/community-guides/geolite2automation"
144145
]
145146
},
146147
"self-host/telemetry",

images/3.jpg

332 KB
Loading
110 KB
Loading

images/maxmind_key-created.jpeg

89.2 KB
Loading
600 KB
Loading

self-host/advanced/enable-geoblocking.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ To enable geoblocking in Pangolin Community you must download and place the Maxm
99
Remember to keep the GeoIP database updated regularly, as IP-to-country mappings can change over time. You can just repeat the download and extraction steps periodically to ensure your database is current.
1010
</Tip>
1111

12+
<Tip>
13+
It is possible to automate this process with a Docker container from Maxmind themself.
14+
Have a look at this [Community guide](/self-host/community-guides/geolite2automation) on how to implement this!
15+
</Tip>
16+
1217
You can use the installer to download and place the database for you, just grab the latest installer:
1318

1419
```bash
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
title: "GeoLite2 Automation"
3+
description: "A simple automation to download & update your GeoLite2 database with geoipupdate"
4+
---
5+
6+
<Note>
7+
This is a community guide and is not officially supported. If you have any issues, please reach out to the [author](https://github.com/txwgnd).
8+
</Note>
9+
10+
This automation lets your system automatically download & upgrade the `GeoLite2-Country` database from Maxmind to use for geoblocking on your Pangolin host. It's utilizing Maxmind's [geoipupdate](https://github.com/maxmind/geoipupdate/tree/main) Docker container to achieve this.
11+
12+
Maxmind's service is free of charge for development, personal or community use. [Quote](https://support.maxmind.com/knowledge-base/articles/create-a-maxmind-account#h_01G4G4NG5C63BQ6HRG6MSS50T3)
13+
14+
# Table of Contents
15+
1. **[Requirements](#1-requirements)**
16+
2. **[Maxmind Account](#2-maxmind-account)**
17+
3. **[API key creation](#3-api-key-creation)**
18+
4. **[Modification of Pangolin's `docker-compose.yml`](#4-modification-of-pangolin’s-docker-compose-yml)**
19+
5. **[Modification of Pangolin's `config.yml`](#5-modification-of-pangolin’s-config-yml)**
20+
21+
## 1. Requirements
22+
* A Maxmind account for API access
23+
* Pangolin version 1.11.0 or higher
24+
25+
## 2. Maxmind Account
26+
To be able to use Maxmind's service you need to request access to the GeoLite2 database and create an account on their [website](https://www.maxmind.com/en/geolite2/signup?utm_source=kb&utm_medium=kb-link&utm_campaign=kb-create-account).
27+
28+
After you successfully created an account visit the mainpage again and login to your new account.
29+
30+
## 3. API key creation
31+
The next step is to create an API key for `geoipupdate`. You'll find an entry called `Manage license keys` in the menu on the left side. Head to this page and click on `Generate new license key`.
32+
33+
<Frame caption="Maxmind's Manage license keys page">
34+
<img src="/images/maxmind_manage-license-keys.jpeg" alt="Maxmind's Manage license keys page" />
35+
</Frame>
36+
37+
Give your new key a name. E.g. `Pangolin`.
38+
39+
<Frame caption="Choose a name for the key">
40+
<img src="/images/maxmind_create-key-page.jpeg" alt="Maxmind's key creation page" />
41+
</Frame>
42+
43+
After your key got created the webpage will show you your Account ID as well as the API key. Save the key now because it can only be seen once. Don't panic if something goes wrong, you can easily create new keys.
44+
45+
<Frame caption="Key successfully created">
46+
<img src="/images/maxmind_key-created.jpeg" alt="The key got created successfully" />
47+
</Frame>
48+
49+
After you clicked on `Return to list` you should see an overview of your keys bundled with some metadata.
50+
51+
## 4. Modification of Pangolin's `docker-compose.yml`
52+
Now login to your Pangolin host and navigate to `/pangolin` in your user directory:
53+
```bash
54+
cd pangolin
55+
```
56+
Shut down Pangolin with:
57+
```bash
58+
docker compose down
59+
```
60+
Open `docker-compose.yml` with your favorite text editor.
61+
E.g. nano:
62+
```bash
63+
nano docker-compose.yml
64+
```
65+
66+
Append this Docker compose service at the end of your stack and add your Account ID as well as your API key you created in the last step:
67+
```yaml
68+
services:
69+
(...)
70+
geoipupdate:
71+
container_name: geoipupdate
72+
image: ghcr.io/maxmind/geoipupdate
73+
restart: unless-stopped
74+
environment:
75+
- 'GEOIPUPDATE_ACCOUNT_ID=' # Account ID
76+
- 'GEOIPUPDATE_LICENSE_KEY=' # API key
77+
- 'GEOIPUPDATE_EDITION_IDS=GeoLite2-Country' # Which db should be downloaded
78+
- 'GEOIPUPDATE_FREQUENCY=72' # Update intervall in hours
79+
volumes:
80+
- './config/GeoLite2:/usr/share/GeoIP'
81+
```
82+
#### Note
83+
If you use the standard Pangolin deployment you shouldn't need to modify the path.
84+
This is the bare minimum to run the container. There are other optional environment variables available. Have a look at their [docs](https://dev.maxmind.com/geoip/updating-databases/?lang=en)!
85+
86+
Save and close the file, but don't restart the stack yet!
87+
88+
## 5. Modification of Pangolin's config.yml
89+
Navigate to `/config` within the same folder and open it with a text editor.
90+
```bash
91+
cd config
92+
```
93+
94+
Add this line to the `server` object
95+
96+
```yaml
97+
server:
98+
maxmind_db_path: "./config/GeoLite2/GeoLite2-Country.mmdb"
99+
```
100+
This entry tells the Pangolin application where to find the database.
101+
102+
Save and close the file then navigate to the `pangolin` folder one level higher.
103+
104+
Restart your Pangolin stack with:
105+
```bash
106+
docker compose up -d
107+
```
108+
109+
Et voilà, you are now able to define country rules for your ressources! 🏁
110+
111+
btw: you can use this exact database for your Traefik dashboard too -> [Community Guide](/self-host/community-guides/traefiklogsdashboard)

0 commit comments

Comments
 (0)