'How do I know if a plugin actually runs or not?

I'm trying out traefik and developing a dummy plugin right now. After countless of errors, I finally get rid all of the errors and don't get any error anymore.

But, the plugin doesn't work as intended. It doesn't throw errors, but it doesn't seem to work either. Is there any way to confirm that the Plugin actually runs? By "running", I mean that I configure it properly, but the function just doesn't return what I want.

This is the output after running the docker compose.

echo-server      | Echo server listening on port 8080.
traefik-proxy    | time="2022-03-21T07:58:28Z" level=info msg="Configuration loaded from flags."

That's just it. No errors, no exit. And it throws a GET log after refreshing the web page, so I assume there are no errors blocking the code. But I'm still not what's wrong. Is it the plugin code or the configuration?

If this is necessary, this is some of my codes:

# docker-compose.yml
version: "3.3"

networks:
  traefik-proxy:

volumes:
  traefik-proxy:

services:
  traefik-proxy:
    image: "traefik:latest"
    container_name: "traefik-proxy"
    networks:
      - traefik-proxy
    command:
      # - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--experimental.localPlugins.traefik-denyuseragent.modulename=github.com/xxx/denyuseragent"
    ports:
      - "80:80"
      - "8080:8080"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./plugins-local/:/plugins-local/

  echo-server:
    image: "xxx/echo-server"
    container_name: "echo-server"
    networks:
      - traefik-proxy
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.echoserver.rule=Host(`echoserver.localhost`)"
      - "traefik.http.routers.echoserver.entrypoints=web"
      - "traefik.http.routers.echoserver.middlewares=traefik-denyuseragent"
# .traefik.yml
displayName: Plugin
type: middleware

import: github.com/xxx/denyuseragent

summary: 'Example'

testData:
  userAgent:
    - Firefox
    - Mozilla/5.0
# traefik.yml
experimental:
  localPlugins:
    traefik-denyuseragent:
      modulename: "github.com/xxx/denyuseragent"
# config.yml
http:
  routers:
    my-router:
      rule: host(`echoserver.localhost`)
      service: service-echoserver
      entryPoints:
        - web
      middlewares:
        - traefik-denyuseragent
      
  services:
    service-echoserver:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:5000
  
  middlewares:
    traefik-denyuseragent:
      plugin:
        traefik-denyuseragent:
          userAgent:
            - Mozilla/5.0

Anyone can confirm if it could work properly or not? Is there some kinds of code I can run to make sure if the Plugin is configured properly or not? Because it'd be great if it is so I can move on to another task, I've spent days just try to configure it.

I just wanna know if the problem is on the plugin or the configuration.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source