github.com/moduit-engineering/cfgeoblock

Whitelist IP Geolocation from Cloudflare


Keywords
traefik-plugin
License
Apache-2.0
Install
go get github.com/moduit-engineering/cfgeoblock

Documentation

Cloudflare GeoBlock plugin for traefik

Cloudflare GeoBlock is a plugin to block traffic based on header Cf-Ipcountry that issued by Cloudflare.

Usage

You need to make sure that traefik is live behind Cloudfare, otherwise the plugin will return HTTP Code 403.

This plugin also will automatically copy the IP from Cf-Connecting-Ip header, so you can chain it with traefik IpWhitelist middleware (https://doc.traefik.io/traefik/middlewares/http/ipwhitelist/)

Configuration

Static Configuration:

pilot:
  token: xxxxx

experimental:
  plugins:
    example:
      moduleName: github.com/moduit-engineering/cfgeoblock
      version: v0.1.4

Dynamic Configuration:

# Dynamic configuration

http:
  routers:
    my-router:
      rule: host(`demo.localhost`)
      service: service-foo
      entryPoints:
        - web
      middlewares:
        - my-plugin
 
  middlewares:
    my-plugin:
      plugin:
        cfgeoblock:
          whitelistCountry: ["ID", "SG"]
          disabled: false #optional