How to install / run plugin from file (offline)

Running traefik 3.0 in docker, I followed instructions to install a plugin - simply add the source info into the static conf, middleware def into dynamic, and add a middleware ref to my apps middleware chain label. Works, great. Digging a little into how it works, I see traefik downloaded a zip archive from github, placed it in /plugins-storage/archives and extracted it's contents into /plugins-storage/sources/gop-3784197768/src.

Now I need to run this plugin on a customer installation, where outgoing access to github is blocked. So I archived /plugins-storage from the working instance, copied it to the offline instance and volume mount it to /plugins-storage.

Unfortunately traefik does not like this - it deletes the files & fails to serve anything.

How can I tell traefik to import the plugin from local file instead of github?

experimental:
  plugins:
    headerdump:
      moduleName: "github.com/jaybubs/headerdump"
      version: "v0.2.0"

There is a reference to a local mode for development here, but the file tree structure of the downloaded zip is different from the Go-workspace. Tried extracting the downloaded code in ./plugins-local/src/github.com/traefik - also fails.

Is there a way to point moduleName to a local file?

Ok, will answer myself: the only way I found to do this is the local mode (already mentioned) - intended for development - the trick is to use a git clone to get the go-workspace, ie not to use the release archive. Also note that the plugins tag is replaced by localPlugins.

Static conf:

experimental:
  localPlugins:
    headerdump:
      moduleName: "github.com/jaybubs/headerdump"`

Dynamic conf:

middlewares:
    my-headerdump:
      plugin:
        headerdump:
          Prefix: HDlog
          TLS: "true"

Then add the my-headerdump middleware to the router with a label.

The directory struct in the traefik container needs to be:

/plugins-local/src/github.com/<plugin owner>/<output of git clone github.com/<plugin owner>/<plugin name>

/plugins-local/src/github.com/jaybubs/headerdump/...

2 Likes