Router not being resolved

I'm using traefik in docker-compose to mimic the "real" setup in kubernetes.
I'm struggling with my router not matching the requests and I'm at a loss to explain why.
Docker-compose snippets:

version: "3"
services:
  vin-provider:
    build: .
    command:
      - vin_api
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.vinprovider.entrypoints=websecure"
      - "traefik.http.routers.vinprovider.rule=Host(`localhost`) && PathPrefix(`/api/my-api`)"
      - "traefik.http.routers.vinprovider.middlewares=vinprovider-strip@docker,vinprovider-headers@docker"
      - "traefik.http.services.vinprovider.loadbalancer.server.port=5000"
      - "traefik.http.middlewares.vinprovider-strip.stripprefix.prefixes=/api/my-api"
      - "traefik.http.middlewares.vinprovider-headers.headers.customrequestheaders.Authorization=Bearer xyz"

and traefik:

  traefik:
    image: traefik:v2.9
    # Enables the web UI and tells Traefik to listen to docker
    # tls uses a generated, self-signed certificate by default
    command:
      - --api.insecure=true
      - --providers.docker
      - --providers.docker.exposedByDefault=false
      - --entrypoints.websecure.address=:4443
      - --log.level=DEBUG
      - --accesslog=true
      - --accesslog.format=json
    ports:
      # The HTTP/s ports
      - 8080:80
      - 4443:4443
      # The Web UI (enabled by --api.insecure=true)
      - 8888:8080
    volumes:
      # So that Traefik can listen to the Docker events
      - /var/run/docker.sock:/var/run/docker.sock

The traefik ui looks as expected:

When I issues requests via browser or curl to https://localhost:4443/api/my-api I see the following access log (in json format):

{
  "ClientAddr": "172.18.0.1:49498",
  "ClientHost": "172.18.0.1",
  "ClientPort": "49498",
  "ClientUsername": "-",
  "DownstreamContentSize": 19,
  "DownstreamStatus": 404,
  "Duration": 72000,
  "Overhead": 72000,
  "RequestAddr": "localhost:4443",
  "RequestContentSize": 0,
  "RequestCount": 381,
  "RequestHost": "localhost",
  "RequestMethod": "GET",
  "RequestPath": "/api/my-api/_info",
  "RequestPort": "4443",
  "RequestProtocol": "HTTP/2.0",
  "RequestScheme": "https",
  "RetryAttempts": 0,
  "StartLocal": "2023-03-16T15:54:25.984506798Z",
  "StartUTC": "2023-03-16T15:54:25.984506798Z",
  "TLSCipher": "TLS_AES_128_GCM_SHA256",
  "TLSVersion": "1.3",
  "level": "info",
  "msg": "",
  "time": "2023-03-16T15:54:25Z"
}

So, the host is localhost and the request path is /api/my-api/_info, but it's seems the request is not resolved to my router.
I played with the PathPrefix, tried Host(`localhost`) alone... all to no avail.

I'm imagining this worked a few months ago when I first created the docker-compose - presumably traefik:2.9 resolved to an earlier release than today.

Would be glad about any hints on how to debug/approach this issue.

Your routers are not TLS enabled, so they won’t match a https request, you get a 404.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.