A high-performance GeoIP-based access control service written in Go suitable for Traefik
965
Where to get help: GitHub
A high-performance GeoIP-based access control service written in Go.
This container is intended for use as a ForwardAuth middleware in Traefik, enabling geo-location based access control for your applications. See Traefik ForwardAuth documentation for integration details.
This service provides IP-based access control using GeoIP lookups and local IP allowlisting. It checks incoming requests against:
Requests are allowed, or blocked, if they match either criteria.
geoipupdate utilityThis service is designed to run with the free MaxMind GeoLite2 Country database. Download and update instructions are available in MaxMind's documentation: https://support.maxmind.com/knowledge-base/articles/download-and-update-maxmind-databases You will need a (free) MaxMind account to obtain an account ID and license key before downloading the database.
GEOIP2_DB (required): Path to GeoIP2 database file (e.g., /data/GeoLite2-Country.mmdb)HOST_ADDR (optional): Server host address to listen on
:80LOCAL_IPS (optional): Comma-separated list of local IP ranges in CIDR notation
192.168.0.0/16,10.0.0.0/8,127.0.0.0/8ACCEPT_COUNTRY_CODES (optional): Comma-separated list of allowed country codes (ISO 3166-1 alpha-2)
US,CA,GB,DEACCEPT_EUROPEAN_UNION (optional): When set to a truthy value (true, 1, yes), allows any country flagged as part of the EU by GeoIP (IsInEuropeanUnion)BLOCK_COUNTRY_CODES (optional): Comma-separated list of blocked country codes (ISO 3166-1 alpha-2)
CN,RU,USACCEPT_COUNTRY_CODES or ACCEPT_EUROPEAN_UNION (mutually exclusive)VERBOSE (optional): Enables verbose logging of allowed and blocked requests
falsevolumes:
geoipupdate_data: {}
services:
traefik:
image: traefik:latest
container_name: traefik_app
restart: unless-stopped
networks:
- default
labels:
traefik.http.middlewares.geoguardian.forwardauth.address: http://geoguardian/
geoipupdate:
container_name: "geoipupdate"
image: ghcr.io/maxmind/geoipupdate:latest
restart: unless-stopped
environment:
GEOIPUPDATE_ACCOUNT_ID: YOUR_ACCOUNT_ID
GEOIPUPDATE_LICENSE_KEY: YOUR_LICENSE_KEY
GEOIPUPDATE_EDITION_IDS: GeoLite2-Country
GEOIPUPDATE_FREQUENCY: 72
volumes:
- "geoipupdate_data:/usr/share/GeoIP"
geoguardian:
container_name: geoguardian
image: nschermer/geo-guardian:latest
restart: unless-stopped
ports:
- "8080:80" # only needed if you want to collect or see metrics
networks:
- default
environment:
GEOIP2_DB: /usr/share/GeoIP/GeoLite2-Country.mmdb
ACCEPT_COUNTRY_CODES: NL,BE,LU
volumes:
- "geoipupdate_data:/usr/share/GeoIP:ro"
Content type
Image
Digest
sha256:a2ebae000…
Size
8.7 MB
Last updated
3 months ago
docker pull nschermer/geo-guardian