Fix GeoIP download (HTTP 403) and clarify host setup

- db-ip.com rejects Python's default "Python-urllib" user agent with
  403; the download now sends "fail2ban-webui/<version> (+repo URL)"
- README quick start: edit .env and replace the example hosts in
  config/hosts.yaml; hosts.yaml.example marks its entries as examples

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
schiwagoaandClaude Opus 5.5 committed 2026-10-25 17:40:14 +01:00
1 parent 97b0c14dac
commit 66a8acd7f9
3 files changed
+8 -1

No files matched your search

+2
View File
@@ -107,8 +107,10 @@ chown -R 10050:10050 data
```bash ```bash
docker compose run --rm -it fail2ban-webui hash-password # Zeile in die .env übernehmen docker compose run --rm -it fail2ban-webui hash-password # Zeile in die .env übernehmen
nano .env # PUBLIC_URL, Hash, DEFAULT_LANG=de …
docker compose run --rm fail2ban-webui keygen # öffentlicher Schlüssel für die Agenten docker compose run --rm fail2ban-webui keygen # öffentlicher Schlüssel für die Agenten
# auf jedem fail2ban-Host den Agenten installieren (docs/agent.md), danach: # auf jedem fail2ban-Host den Agenten installieren (docs/agent.md), danach:
nano config/hosts.yaml # Beispiel-Hosts durch deine ersetzen!
docker compose run --rm -it fail2ban-webui keyscan docker compose run --rm -it fail2ban-webui keyscan
docker compose run --rm fail2ban-webui check docker compose run --rm fail2ban-webui check
docker compose up -d docker compose up -d
+4 -1
View File
@@ -24,6 +24,7 @@ from datetime import date, datetime, timedelta
import maxminddb import maxminddb
log = logging.getLogger("webui") log = logging.getLogger("webui")
USER_AGENT = "fail2ban-webui/{} (+https://git.retronerd.at/schiwagoa/fail2ban-webui)"
def fail(key, **args): def fail(key, **args):
@@ -93,8 +94,10 @@ class Geo:
first = date.today().replace(day=1) first = date.today().replace(day=1)
for month in (first, (first - timedelta(days=1)).replace(day=1)): for month in (first, (first - timedelta(days=1)).replace(day=1)):
url = f"https://download.db-ip.com/free/dbip-city-lite-{month:%Y-%m}.mmdb.gz" url = f"https://download.db-ip.com/free/dbip-city-lite-{month:%Y-%m}.mmdb.gz"
# db-ip.com answers 403 to Python's default "Python-urllib" user agent
req = urllib.request.Request(url, headers={"User-Agent": USER_AGENT.format(self.settings.version)})
try: try:
with urllib.request.urlopen(url, timeout=300) as resp, \ with urllib.request.urlopen(req, timeout=300) as resp, \
tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as tmp: tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) as tmp:
with gzip.GzipFile(fileobj=resp) as gz: with gzip.GzipFile(fileobj=resp) as gz:
shutil.copyfileobj(gz, tmp) shutil.copyfileobj(gz, tmp)
+2
View File
@@ -8,6 +8,8 @@
# #
# After changes: docker compose run --rm -it fail2ban-webui keyscan # After changes: docker compose run --rm -it fail2ban-webui keyscan
# docker compose restart # docker compose restart
#
# The three entries below are EXAMPLES – replace them with your own hosts.
# ===================================================================== # =====================================================================
hosts: hosts:
- name: web01 - name: web01