jittering / traefik-kop

A dynamic docker->redis->traefik discovery agent
MIT License
179 stars 13 forks source link

traefik.http.routers.example.rule: 'Host(`example.com`) && Path(`/example/`)' does not work #22

Closed Svenum closed 1 year ago

Svenum commented 1 year ago

The label:

traefik.http.routers.example.rule: 'Host(`example.com`) && Path(`/example/`)'

does not work, but:

traefik.http.routers.example.rule: 'Host(`example.com`)'

does work.

chetan commented 1 year ago

@Svenum were you able to confirm that the rule is showing up in Traefik as you expect it to? If so, I think the issue is not in traefik-kop, but either in your rule or in traefik itself.

Svenum commented 1 year ago

If I add the rule traefik-kop dont show that its commiting this rule for that service (in the logs) to redis. If I am only add:

traefik.http.routers.example.rule: 'Host(`example.com`)'

it shows, that it is commiting this rule.

chetan commented 1 year ago

Gotcha. I'll take a look and see what's going on with that.

chetan commented 1 year ago

Just ran a simple test and I'm able to see the rule in redis:

# compose file
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.hellopath.rule=Host(`hello1.local`) && Path(`/subdir/`)"
      - "traefik.http.routers.hellopath.service=hellopath"
      - "traefik.http.routers.hellopath.tls=true"
      - "traefik.http.routers.hellopath.tls.certresolver=default"
      - "traefik.http.services.hellopath.loadbalancer.server.scheme=http"
      - "traefik.http.services.hellopath.loadbalancer.server.port=5590"

kop debug output:

time="2023-02-08T09:14:12-05:00" level=debug msg="writing traefik/http/routers/hellopath/rule = Host(`hello1.local`) && Path(`/subdir/`)"
time="2023-02-08T09:14:12-05:00" level=debug msg="writing traefik/http/routers/hellopath/tls/certResolver = default"

redis:

127.0.0.1:6380> get traefik/http/routers/hellopath/rule
"Host(`hello1.local`) && Path(`/subdir/`)"
Svenum commented 1 year ago

Ok, I will Look if I have an Error.

chetan commented 1 year ago

The only bits that get modified in any way are the service host/port, depending on how things are configured. The rule should be getting passed through as-is, based on how traefik (I use their package to read the labels) is picking it up from docker.

Svenum commented 1 year ago

Is it possible that traefik-kop only add Healthy services?

chetan commented 1 year ago

There's nothing specific to traefik-kop around healthchecks. I did some testing recently to ensure that services were being picked up correctly when a healthcheck is present, but there are no checks inside kop around this. traefik itself may be ignoring unhealthy services, but I'm not sure. You should be able to see in the debug logs if it's being picked up at all.

Svenum commented 1 year ago

Got this message in traefik-kop:

time="2023-02-08T15:04:56Z" level=debug msg="Filtering unhealthy or starting container" providerName=docker container=container=brave-neko-43f88eedf49fe7f08ea353280180ba963f85217b4b9d8ede643035cfbaa83d20

That is my missing service.

But its not shown up at writint or found stage.

Svenum commented 1 year ago

If i disable the healthcheck (so it does not show unhealthy) it works fine.

chetan commented 1 year ago

Right, that message is coming from traefik internals when reading the containers from docker. When it turns healthy, it should get published correctly. If you explicitly want to publish unhealthy services, there may be some setting within traefik to do that, but I'm not aware of it.

Svenum commented 1 year ago

Ok, I thought, that this debug messages in traefik-kop are only form traefik-kop and not from traefik directly. Thank you for your help.