Using Plugins

    Experimental Features

    Plugins can potentially modify the behavior of Traefik in unforeseen ways. Exercise caution when adding new plugins to production Traefik instances.

    To add a new plugin to a Traefik instance, you must modify that instance’s static configuration. The code to be added is provided by the Traefik Pilot UI when you choose Install the Plugin.

    In the example below, we add the and plugins:

    File (YAML)

    1. entryPoints:
    2. web:
    3. address: :80
    4. pilot:
    5. token: xxxxxxxxx
    6. experimental:
    7. plugins:
    8. block:
    9. modulename: github.com/traefik/plugin-blockpath
    10. version: v0.2.0
    11. version: v0.3.0

    CLI

    1. --entryPoints.web.address=:80
    2. --pilot.token=xxxxxxxxx
    3. --experimental.plugins.block.modulename=github.com/traefik/plugin-blockpath
    4. --experimental.plugins.block.version=v0.2.0
    5. --experimental.plugins.rewrite.modulename=github.com/traefik/plugin-rewritebody
    6. --experimental.plugins.rewrite.version=v0.3.0

    Configuring Plugins

    Some plugins will need to be configured by adding a dynamic configuration. For the bodyrewrite plugin, for example:

    Docker

    1. apiVersion: traefik.containo.us/v1alpha1
    2. kind: Middleware
    3. metadata:
    4. name: my-rewritebody
    5. spec:
    6. plugin:
    7. rewrites:
    8. - regex: example
    9. replacement: test

    Consul Catalog

    1. - "traefik.http.middlewares.my-rewritebody.plugin.rewrite.rewrites[0].regex=example"
    2. - "traefik.http.middlewares.my-rewritebody.plugin.rewrite.rewrites[0].replacement=test"

    Marathon

    Rancher

    1. labels:
    2. - "traefik.http.middlewares.my-rewritebody.plugin.rewrite.rewrites[0].regex=example"
    3. - "traefik.http.middlewares.my-rewritebody.plugin.rewrite.rewrites[0].replacement=test"

    File (TOML)

    1. [http.middlewares]
    2. [http.middlewares.my-rewritebody.plugin.rewrite]
    3. lastModified = true
    4. [[http.middlewares.my-rewritebody.plugin.rewrite.rewrites]]
    5. regex = "example"
    6. replacement = "test"