Problem with on service pathPrefix(`/`)

Hello, I have some problems, I think that this practice don´t run, but i want ask, why?

When I use PathPrefix(`/`) I don´t have a good route and the request to traefik dashboard is respond by the service webservice

I have traefik with this configuration:

function create_service {
                docker service create \
                --name traefik \
                --publish 80:80 \
                --publish 8080:8080 \
                --mount "type=bind,src=/var/run/docker.sock,target=/var/run/docker.sock" \
                --network ${NETWORK_TRAEFIK} \
                --with-registry-auth \
                --constraint 'node.role==manager' \
                --label traefik.enable=true \
                --label "traefik.http.routers.traefik.rule=Host(`traefik.domain.com`)" \
                --label traefik.docker.network=${NETWORK_TRAEFIK} \
                --label traefik.http.services.traefik.loadbalancer.server.port=8080 \
               traefik:v2.1 \
                --api.insecure=true \
                --providers.docker.endpoint=unix:///var/run/docker.sock \
                --providers.docker.swarmMode=true \
                --api.dashboard \
                --providers.docker.exposedbydefault=false \
                --providers.docker.network=proxy \
                --entrypoints.web.address=:80 \
                --log.level=DEBUG

also, I have a service with some PathPrefix

    docker service create \
    --name  webservice \
    --network proxy \
    --label "traefik.enable=true" \
    --label "traefik.http.services.webservice.loadbalancer.server.port=80" \
    --label "traefik.http.routers.webservice.rule=Host(`webservice.domain`) \
    && PathPrefix(`/siteone`) \
    || PathPrefix(`/sitetwo`) \
    || PathPrefix(`/`) \
    || PathPrefix(`/sitethree`)" \
   nginx

I can´t use PathPrefix(`/`) ?

Thanks!

Hello,

I strongly recommend to use the secure mode to create routing for the dashboard.

https://docs.traefik.io/v2.1/operations/dashboard/#secure-mode

Your problem is a boolean expression issue:

--label "traefik.http.routers.webservice.rule=Host(`webservice.domain`) \
    && PathPrefix(`/siteone`) \
    || PathPrefix(`/sitetwo`) \
    || PathPrefix(`/`) \
    || PathPrefix(`/sitethree`)" \

=> A && B || C || D || E is different than A && (B || C || D || E)

so you have to add parenthesis:

--label "traefik.http.routers.webservice.rule=Host(`webservice.domain`) \
    && (PathPrefix(`/siteone`) \
    || PathPrefix(`/sitetwo`) \
    || PathPrefix(`/`) \
    || PathPrefix(`/sitethree`))" \

Hi @ldez

Thank you for your recommendation I´m apply it, and yes, my problem is the parenthesis: smiley:
Thanks !!!