Skip to content
/ torblock Public
forked from jpxd/torblock

Traefik plugin for blocking traffic from the Tor network

License

Notifications You must be signed in to change notification settings

gpb88/torblock

 
 

Repository files navigation

TorBlock

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.

Configuration

Requirements: Traefik >= v2.5.5

Static

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 configuration
pilot:
  token: xxxxx

experimental:
  plugins:
    torblock:
      moduleName: github.com/jpxd/torblock
      version: 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 configuration

http:
  routers:
    my-router:
      rule: host(`demo.localhost`)
      service: service-foo
      entryPoints:
        - web
      middlewares:
        - my-middleware

  services:
   service-foo:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:5000
  
  middlewares:
    my-middleware:
      torblock:
        enabled: true

Local Mode

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 configuration
pilot:
  token: xxxxx

experimental:
  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 configuration

http:
  routers:
    my-router:
      rule: host(`demo.localhost`)
      service: service-foo
      entryPoints:
        - web
      middlewares:
        - my-middleware

  services:
   service-foo:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:5000
  
  middlewares:
    my-middleware:
      plugin:
        torblock:
          enabled: true

Examples

You can also see a working example docker-compose.yml in the examples directory, which loads the plugin in local mode.

About

Traefik plugin for blocking traffic from the Tor network

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 97.4%
  • Makefile 2.6%