The middleware is being ignored (middleware-manager discussion #25)

:speech_balloon: GitHub discussion middleware-manager #25 in General, started by Rihan9 on GitHub

hi,
I’m using pangolin almost as default and I set up one of my resource with authelia middleware, but it is being ignored. Do I need to edit in some way traefik_config.yml or dynamic_config.yml?

My docker-compose.yml:

name: pangolin
services:
  beszel-agent:
    image: "henrygd/beszel-agent"
    container_name: "beszel-agent"
    restart: unless-stopped
    network_mode: host
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      # monitor other disks / partitions by mounting a folder in /extra-filesystems
      # - /mnt/disk/.beszel:/extra-filesystems/sda1:ro
    environment:
      LISTEN: 45876
      KEY: "{{OMITTED}}"
  middleware-manager:
    image: hhftechnology/middleware-manager:latest
    container_name: middleware-manager
    restart: unless-stopped
    depends_on:
      - gerbil
    volumes:
      - ./data:/data
      - ./config/traefik/rules:/conf
      - ./config/middleware-manager/templates.yaml:/app/config/templates.yaml  # Optional for custom templates
    environment:
      - PANGOLIN_API_URL=http://pangolin:3001/api/v1
      - TRAEFIK_CONF_DIR=/conf
      - DB_PATH=/data/middleware.db
      - PORT=3456
#    ports:
#      - "3456:3456"
  pangolin:
    image: fosrl/pangolin:1.2.0
    container_name: pangolin
    restart: unless-stopped
    volumes:
      - ./config:/app/config
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:3001/api/v1/"]
      interval: "3s"
      timeout: "3s"
      retries: 5

  gerbil:
    image: …

---
💬 Join in here or [on GitHub](https://github.com/hhftechnology/middleware-manager/discussions/25).
<!-- hhf-forum-sync -->

hhftechnology commented on GitHub:

this is yours
External Image

this is how it should be

External Image

External Image

External Image

Rihan9 commented on GitHub:

Ok, now I have:

  • 400 - bad request if I use the public url of my authelia server
    there is an error on authelia log:
time="2025-04-29T17:00:38Z" level=error msg="Error getting Target URL and Request Method" error="header 'X-Forwarded-Method' is empty" method=GET path=/api/authz/forward-auth remote_ip=172.18.0.1

I’ll dig more about it

  • 500 - internal server error if I use the internal hostname of my authelia. It is on my local machine, not in the VPS so I tried to add:
network_mode: service:gerbil

in the docker-compose.yaml, but I don’t think it’s working. No error is displayed in the docker logs:

External Image

hhftechnology commented on GitHub:

middleware-manager is running fine. its networking issue. because traefik is routed through gerbil. please check traefik logs.

Rihan9 commented on GitHub:

Hi,
no files are present in ./config/traefik/logs

no revelant logs with the command docker logs traefik:

External Image

the previous screenshot was the output of “docker compose up”, so all the container logs where written in the output

oidebrett commented on GitHub:

Have you tried accessing the Traefik dashboard so that you can see if there are any errors in how the middlewares are being applied? Traefik dashboard is on port localhost:8080 and if you set it up as an authenticated pangolin resource you will be able to access it securely. Very helpful for checking if middlewares applied properly.

Roving-Ronin commented on GitHub:

@​oidebrett how do you do this? I already have a second site that is ‘Local’ and publish the Middleware Manager to myself this way.
Trying to access Traefik, given its via Gerbil, I’ve got the target as Hostname = gerbil and Port = 8080 and when trying to access the page comes up with ‘Bad Gateway’ ?

Rihan9 commented on GitHub:

Here:

External Image

External Image

I tried to add one of the X-Forwarded headers, but no canghe has been detected afterwards.

@​oidebrett how do you do this? I already have a second site that is ‘Local’ and publish the Middleware Manager to myself this way. Trying to access Traefik, given its via Gerbil, I’ve got the target as Hostname = gerbil and Port = 8080 and when trying to access the page comes up with ‘Bad Gateway’ ?

For me the configuration worked at first try. Do you have the following code in your traefik_config.yml?

api:
  insecure: true
  dashboard: true

For me these are the very first rows

Rihan9 commented on GitHub:

You know, @​oidebrett, now the middleware is being loaded correctly, so I don’t think this is an issue for middleware-manager anymore.

Can I just ask you to update the README.md to add a section related to how to modify the traefik configuration?
I came from another reverse proxy so that wasn’t clear for me at all

oidebrett commented on GitHub:

You may have to add headers as a middleware. I havent tried authelia but I needed to do this for other Idps

  - id: cors-headers
    name: CORS Headers
    type: headers
    config:
      accessControlAllowMethods:
        - GET
        - POST
        - OPTIONS
      accessControlAllowOriginList:
        - "*"
      accessControlAllowHeaders:
        - Authorization
        - Content-Type
        - mcp-protocol-version
      accessControlMaxAge: 86400
      accessControlAllowCredentials: true
      addVaryHeader: true

Rihan9 commented on GitHub:

But if I use the Ip retrieved from the traefik dashboard the authentication works fine and I don’t see any CORS errors in the authelia logs (you can see my latest comment onthe issue opened in pangolin).
Maybe it’s because for some endpoints authelia apply some cors rules by default