Hello everyone,
I'm building a Traefik plugin middleware that extracts the Authorization header, verifies its validity via a gRPC call to our Auth service, and adds necessary headers for subsequent requests.
Since Yaegi doesn't support importing external packages, I opted to use WebAssembly (WASM) and followed the demo plugin for HTTP calls. I compiled the .wasm
file successfully (reference: GitHub demo).
Here’s my traefik.yml
:
displayName: Plugin for getting payload
runtime: wasm
type: middleware
summary: 'Add payload from token'
testData:
HeaderName: X-AUTH
And my docker-compose.yml
configuration:
reverse-proxy:
image: traefik:v3.1.2
command:
- "--log.level=DEBUG"
- "--api=true"
- "--api.dashboard=true"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--providers.file.filename=./dynamic.yml"
- "--experimental.localPlugins.enabled=true"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--entryPoints.postgres.address=:10000"
- "--experimental.plugins.enabled=true"
- "--experimental.localPlugins.traefik-auth-plugin.moduleName=github.com/LevisThors/traefik-auth-plugin"
ports:
- 80:80 # HTTP
- 443:443 # HTTPS
- 10000:10000 # Postgres # TODO: close in production
labels:
- "traefik.enable=true"
- "traefik.http.services.reverse-proxy.loadbalancer.server.port=8080"
- "traefik.http.routers.to-reverse-proxy.entrypoints=web,websecure"
- "traefik.http.routers.to-reverse-proxy.rule=Host(`traefik.${SITE_DOMAIN}`)"
networks:
- random_network
volumes:
- ./plugins-local:/plugins-local
- ./dynamic.yml:/dynamic.yml
- /var/run/docker.sock:/var/run/docker.sock:ro
Here’s my dynamic.yml
:
http:
routers:
to-exchange-rate_service:
rule: "Host(`${SITE_DOMAIN}`) && PathPrefix(`/api/accounts/exchange-rates`)"
service: exchange-rate_service
entryPoints:
- web
- websecure
middlewares:
- traefik-auth-plugin
services:
exchange-rate_service:
loadBalancer:
servers:
- url: "http://exchange-rates_service:8000"
middlewares:
traefik-auth-plugin:
plugin:
traefik-auth-plugin:
example: "SOMETHING"
tls:
options:
default:
minVersion: VersionTLS12
Despite the middleware showing up on the dashboard, I get the following error:
invalid middleware "traefik-auth-plugin@file" configuration: invalid middleware type or middleware does not exist
Has anyone encountered a similar issue? What steps can I take to resolve this?