TorBlock is a Traefik plugin which can block requests originating from the Tor network. The publicly available list of Tor exit nodes (https://check.torproject.org/exit-addresses
) is fetched regularly in order to identify the requests to be blocked.
Requirements: Traefik >= v2.5.5
For each plugin, the Traefik static configuration must define the module name (as is usual for Go packages).
The following declaration (given here in YAML) defines an plugin:
# Static configurationpilot:token: xxxxxexperimental:plugins:torblock:moduleName: github.com/jpxd/torblockversion: v0.1.1
Here is an example of a file provider dynamic configuration (given here in YAML), where the interesting part is the http.middlewares
section:
# Dynamic configurationhttp:routers:my-router:rule: host(`demo.localhost`)service: service-fooentryPoints:- webmiddlewares:- my-middlewareservices:service-foo:loadBalancer:servers:- url: http://127.0.0.1:5000middlewares:my-middleware:torblock:enabled: true
Traefik also offers a developer mode that can be used for temporary testing or offline usage of plugins not hosted on GitHub. To use a plugin in local mode, the Traefik static configuration must define the module name (as is usual for Go packages) and a path to a Go workspace, which can be the local GOPATH or any directory.
The plugins must be placed in ./plugins-local
directory, which should be next to the Traefik binary.
The source code of the plugin should be organized as follows:
./plugins-local/
└── src
└── github.com
└── jpxd
└── torblock
├── torblock.go
├── torblock_test.go
├── go.mod
├── LICENSE
├── Makefile
└── README.md
# Static configurationpilot:token: xxxxxexperimental:localPlugins:example:moduleName: github.com/jpxd/torblock
(In the above example, the torblock
plugin will be loaded from the path ./plugins-local/src/github.com/jpxd/torblock
.)
# Dynamic configurationhttp:routers:my-router:rule: host(`demo.localhost`)service: service-fooentryPoints:- webmiddlewares:- my-middlewareservices:service-foo:loadBalancer:servers:- url: http://127.0.0.1:5000middlewares:my-middleware:plugin:torblock:enabled: true
You can also see a working example docker-compose.yml
in the examples
directory, which loads the plugin in local mode.