Giter Site home page Giter Site logo

traefikgeoip2's Introduction

Traefik plugin for MaxMind GeoIP2

Traefik plugin that registers a custom middleware for getting data from MaxMind GeoIP databases and pass it downstream via HTTP request headers.

Supports both GeoIP2 and GeoLite2 databases.

Configuration

We're using this plugin in Kubernetes, thus the configuration guide is Kubernetes oriented.

You are welcome:

  • refer to the Traefik configuraiton documentation for other orchestration frameworks.
  • contribute to this README about the configuraion for other orchestration environments.

Create custom Traefik Docker image

This is ~required in Kubernetes, since MaxMind DB size is bigger, than data size allowed for ConfigMap or Secret resource.

Assuming you want to try free GeoLite2 database, that is already downloaded locally.

  1. Create custom Dockerfile

    FROM traefik:2.4.9
    COPY GeoLite2-City.mmdb /var/lib/traefikgeoip2/ 
    
  2. Build and publish to a Docker registry

    export TDR=${...}
    docker build -t ${TDR}/traefik:2.4.9 .
    docker push ${TDR}/traefik:2.4.9
    
    

Enable plugin in Traefik

We recommend to use official Helm chart for installing Traefik into Kubernetes cluster.

Below, there's an instruction for adjusting official Helm chart to install the plugin.

  1. Create a file named traefik.yaml, replacing ${TDR} with actual Docker registry path.

    image:
      name: ${TDR}/traefik
      tag: "2.4.9"
    
    pilot:
      enabled: true
      token: "${TRAEFIK_PILOT_TOKEN}"
    
    additionalArguments:
      - "--experimental.plugins.geoip2.modulename=github.com/GiGInnovationLabs/traefikgeoip2"
      - "--experimental.plugins.geoip2.version=v0.1.1"
  2. Install customized Traefik Helm chart.

    helm repo add traefik https://helm.traefik.io/traefik
    helm repo update
    helm upgrade --install -n traefik --create-namespace \
      my-traefik traefik/traefik --version 10.1.1 -f ./traefik.yaml      

Create Traefik Middleware

  1. Create a file named mw.yaml

    apiVersion: traefik.containo.us/v1alpha1
    kind: Middleware
    metadata:
      name: geoip2
      namespace: traefik
    spec:
      plugin:
        geoip:
          dbPath: "/var/lib/geoip2/GeoLite2-City.mmdb"
  2. Apply

    kubectl apply -f mw.yaml

Apply GeoIP2 middleware to Traefik route

!!! warning TO BE DEFINED

Development

To run linter and tests execute this command

make prepare
make

traefikgeoip2's People

Contributors

ievgenii-shepeliuk avatar eshepelyuk avatar

Stargazers

Lukasz Raczylo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.