GRPC auth middleware issue

Hi Guys,

I want to use traefik as a grpc proxy api. It should forward the grpc request to an authmiddleware. I made a demo a few days ago and it worked, but now in my project it does not work. My grpc call receives 500 error code. When i disable authmiddleware the grpc works. Could you help me what am I missing?

The relevant docker compose parts:

traefik:
    image: "traefik:v3.2"
    container_name: "traefik"
    command:
      #- "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entryPoints.web.address=:80" # HTTP/1
      # - "--entryPoints.websecure.address=:443" # HTTPS
      # - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
      - "--providers.file.filename=/dynamic.yaml"
    ports:
      - "80:80"
      # - "443:443"
      - "8080:8080"

user_service:
    image: gardenzillaorg/user_service:latest
    container_name: user_service
    build:
      context: .
      dockerfile: Dockerfile
      args:
        - SERVICE_NAME=user_service
    restart: always
    env_file:
      - ENV.list
    networks:
      - gz_network
    depends_on:
      mongo:
        condition: service_started
      kafka:
        condition: service_healthy
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.user_service.rule=Host(`api.user.localhost`)"
      - "traefik.grpc.services.user_service.loadbalancer.server.url=http://user_service"
      - "traefik.http.services.user_service.loadbalancer.server.port=40051"
      - "traefik.http.services.user_service.loadbalancer.server.scheme=h2c"
      - "traefik.http.middlewares.mooncar-grpc.grpcWeb.allowOrigins=*"
      - "traefik.http.routers.user_service.middlewares=authMiddleware@file"

dynamic.yaml

http:
  middlewares:
    authMiddleware:
      forwardAuth:
        address: "http://auth_service:3000/validate"
        trustForwardHeader: true
        authResponseHeaders:
          # - "X-User-Id"
          - "X-Token"
          # - "X-Roles"
          # - "X-Created-At"

Thank you in advance

Enable and check Traefik debug log (doc) and Traefik access log in JSON format (doc).

Ok so basically my interceptor service tricked me and returned 500 to every request. Its a bit annoying, but your advice helped me to put my leg on the solution path anyway. Thank you.

And if you are doing managed state with Actix or Rocket watch the details, .manage(Arc<T>) is not equal with &State<T> ... just spent 2 days for this shitty bug. Thank you. :slight_smile: