https://github.com/agence-gaya/traefik-plugin-blockuseragent
Block User-Agent
https://github.com/agence-gaya/traefik-plugin-blockuseragent
traefik-plugin
Last synced: 6 months ago
JSON representation
Block User-Agent
- Host: GitHub
- URL: https://github.com/agence-gaya/traefik-plugin-blockuseragent
- Owner: agence-gaya
- License: apache-2.0
- Created: 2021-04-09T01:10:34.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-21T23:27:37.000Z (about 2 years ago)
- Last Synced: 2024-06-23T13:40:52.273Z (about 2 years ago)
- Topics: traefik-plugin
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 6
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Block User-Agent
[](https://github.com/agence-gaya/traefik-plugin-blockuseragent/actions)
Block User-Agent is a middleware plugin for [Traefik](https://github.com/traefik/traefik) which sends an HTTP `403 Forbidden`
response when the requested HTTP User-Agent header matches one the configured [regular expressions](https://github.com/google/re2/wiki/Syntax).
## Configuration
## StaticUpdate
```toml
[pilot]
token="xxx"
[experimental.plugins.blockuseragent]
modulename = "github.com/agence-gaya/traefik-plugin-blockuseragent"
version = "vX.Y.Z"
```
## Dynamic
To configure the `Block User-Agent` plugin you should create a [middleware](https://docs.traefik.io/middlewares/overview/) in
your dynamic configuration as explained [here](https://docs.traefik.io/middlewares/overview/). The following example creates
and uses the `blockuseragent` middleware plugin to block all HTTP requests with a User-Agent like `\bTheAgent\b`.
You can use regexAllow to make exception on blocking regex.
```toml
[http.routers]
[http.routers.my-router]
rule = "Host(`localhost`)"
middlewares = ["block-foo"]
service = "my-service"
# Block all user agent containing TheAgent except if containing Allowed word
[http.middlewares]
[http.middlewares.block-foo.plugin.blockuseragent]
regexAllow = ["\bAllowed\b"]
regex = ["\bTheAgent\b"]
[http.services]
[http.services.my-service]
[http.services.my-service.loadBalancer]
[[http.services.my-service.loadBalancer.servers]]
url = "http://127.0.0.1"
```