Plugins for getting the country code of the client ip from ip2location database and redirect to specific url when (no)match the target countries
To configure this plugin you should add its configuration to the Traefik dynamic configuration as explained here. The following snippet shows how to configure this plugin with the File provider in TOML and YAML:
Static:
experimental:
pilot:
token: xxx
plugins:
ip2location_redirect:
modulename: github.com/jiangwennn/traefik-plugin-ip2location-redirect
version: v0.1.0
Dynamic:
http:
middlewares:
my-plugin:
plugin:
ip2location_redirect:
filename: path/to/database.bin
regions: ["CN"],
redirectUrl: "https://github.com"
noMatch: false # optional
permanent: false # optional
fromHeader: X-User-IP # optional
disableErrorHeader: false # optional
filename
| string
| Required
The path to ip2location database file (in binary format), and it must be in the working directory of the process running the Traefik binary
regions
| []string
| Required
Array of country codes in 2 letters, eg: CN
,UK
redirectUrl
| string
| Required
The url address redirect to
noMatch
| bool
| Default: false
If true
, redirect action performs when the ip doesn't belong to any of the regions configured
permanent
| bool
| Default: false
If true
, redirect status code will be 301 Moved Permanently
, otherwise 302 Found
fromHeader
| string
| Default: empty
If defined, IP address will be obtained from this HTTP header. Remote-Addr
By default.
disableErrorHeader
| bool
| Default: false
If any error occurred, this error will be placed to X-IP2LOCATION-REDIRECT-ERROR header
-
traefik-plugin-ip2location
-
Country Codes