You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# GeoBlock
2
2
3
-
Simple plugin for [Traefik](https://github.com/containous/traefik) to block request based on their country of origin. Uses [GeoJs.io](https://www.geojs.io/).
3
+
Simple plugin for [Traefik](https://github.com/containous/traefik) to block or allow requests based on their country of origin. Uses [GeoJs.io](https://www.geojs.io/).
4
4
5
5
## Configuration
6
6
@@ -10,9 +10,9 @@ It is possible to install the [plugin locally](https://traefik.io/blog/using-pri
10
10
11
11
Depending on your setup, the installation steps might differ from the one described here. This example assumes that your Traefik instance runs in a Docker container and uses the [official image](https://hub.docker.com/_/traefik/).
12
12
13
-
Download the latest release of the plugin and save it to a location the Traefik container can reach. Below is an example of a possible setup. Notice how the plugin source is mapped into the container (`/plugin/geoblock:/plugins-local/src/github.com/PascalMinder/geoblock/`):
13
+
Download the latest release of the plugin and save it to a location the Traefik container can reach. Below is an example of a possible setup. Notice how the plugin source is mapped into the container (`/plugin/geoblock:/plugins-local/src/github.com/PascalMinder/geoblock/`) via a volume bind mount:
To complete the setup, the Traefik configuration must be extended with the plugin. For this you must create the `traefik.yml` and the dynamic-configuration.yml` files if not present already.
44
44
45
-
traefik.yml
46
-
47
45
````yml
48
46
log:
49
47
level: INFO
@@ -54,7 +52,7 @@ experimental:
54
52
moduleName: github.com/PascalMinder/geoblock
55
53
````
56
54
57
-
dynamic-configuration.yml
55
+
#### `dynamic-configuration.yml`
58
56
59
57
````yml
60
58
http:
@@ -76,16 +74,13 @@ http:
76
74
- CH
77
75
````
78
76
79
-
### Traefik Pilot
77
+
### Traefik Plugin registry
80
78
81
-
To install the plugin with Traefik Pilot, follow the instruction on their website.
79
+
This procedure will install the plugin via the [Traefik Plugin registry](https://plugins.traefik.io/install).
82
80
83
81
Add the following to your `traefik-config.yml`
84
82
85
83
```yml
86
-
pilot:
87
-
token: "xxxx-your-token-xxxx"
88
-
89
84
experimental:
90
85
plugins:
91
86
GeoBlock:
@@ -166,6 +161,7 @@ This configuration might not work. It's just to give you an idea how to configur
166
161
- `logLocalRequests`: If set to true, will log every connection from any IP in the private IP range
167
162
- `api`: API URI used for querying the country associated with the connecting IP
168
163
- `countries`: list of allowed countries
164
+
- `backListMode`: set to `false` so the plugin is running in `whitelist mode`
169
165
170
166
````yml
171
167
my-GeoBlock:
@@ -181,6 +177,7 @@ my-GeoBlock:
181
177
forceMonthlyUpdate: false
182
178
allowUnknownCountries: false
183
179
unknownCountryApiResponse: "nil"
180
+
backListMode: false
184
181
countries:
185
182
- AF # Afghanistan
186
183
- AL # Albania
@@ -471,10 +468,14 @@ Even if an IP stays in the cache for a period of a month (about 30 x 24 hours),
471
468
472
469
Some IP addresses have no country associated with them. If this option is set to true, all IPs with no associated country are also allowed.
473
470
474
-
### Unknown country api response`unknownCountryApiResponse`
471
+
### Unknown country api response`unknownCountryApiResponse`
475
472
476
473
The API uri can be customized. This options allows to customize the response string of the API when a IP with no associated country is requested.
477
474
475
+
### Back list mode `blackListMode`
476
+
477
+
When set to `true` the filter logic is inverted, i.e. requests originating from countries listed in the [`countries`](#countries-countries) list are **blocked**. Default: `false`.
478
+
478
479
### Countries `countries`
479
480
480
-
A list of country codes from which connections to the service should be allowed
481
+
A list of country codes from which connections to the service should be allowed. Logic can be inverted by using the [`blackListMode`](#back-list-mode-blacklistmode).
0 commit comments