Problems matching Path and PathPrefix in Traefik

Using Traefix version 1.2.3 from a docker container I have installed the following file.

traefik:
  image: traefik
  command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG
  ports:
    - "80:80"
    - "8080:8080"
    - "443:443"
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - /dev/null:/traefik.toml  

services:
  image: opencoredata/ocdservices:0.2
  labels:
    - "traefik.backend=services"
    - "traefik.frontend.rule=Host:opencore.dev"
    - "traefik.frontend.rule=PathPrefix:/api"

# web:
#   image: opencoredata/ocdweb:0.3
#   labels:
#     - "traefik.backend=web"
#     - "traefik.frontend.rule=Host:opencore.dev"

      

If I remove the comments around the Internet section, all traffic goes to that container, ignoring the Path or PathPrefix or any other attempt to get URLs starting with / api / to go to the services container.

Commenting out the "Internet" container as above and the traffic goes to the services container. Of course there is no other container.

I just can't seem to find how to get Traefik to work with Path, PathPrefix, PathPrefixStrip, or any other combination. The examples here and in the docs show that I should get the behavior I want, but I can't figure it out.

+3


source to share


1 answer


I think this part

- "traefik.frontend.rule=Host:opencore.dev"
- "traefik.frontend.rule=PathPrefix:/api"

      

is wrong because the second line overwrites the first, try this:



- "traefik.frontend.rule=Host:opencore.dev;PathPrefix:/api"

      

I think he will combine material the way you want.

+6


source







All Articles