PathPrefix shows no effect

Hello dear friends of Traefik.
Once again I have problems with a configuration.
95% of the time it's because I just don't see the little errors. Once it took me half a day to realise that I had used ' instead of `. I'm getting old.

This time I would like to forward a directory to another server. So I installed a web service and also PGadmin to manage the database and I want Traefik to redirect it accordingly.

Here is my dynamic V2 configuration.

http:
  routers:
    mywebservice-pgadmin-router-https:
      entryPoints:
        - "https"
      rule: "Host(`mywebservice.mydomain.net`) && PathPrefix(`/pgadmin`)"
      service: service-mywebservice-pgadmin
      priority: 1
      tls:
        certResolver: letsEncrypt

    mywebservice-router-https:
      entryPoints:
        - "https"
      rule: "Host(`mywebservice.mydomain.net`)"
      service: service-mywebservice
      priority: 2
      tls:
        certResolver: letsEncrypt

  services:
    service-mywebservice:
      loadBalancer:
        serversTransport: mywebservice-transport
        servers:
          - url: "https://myinternwebservice.local:8443"

    service-mywebservice-pgadmin:
      loadBalancer:
        serversTransport: mywebservice-transport
        servers:
          - url: "http://myinternwebservice.local:5050"

  serversTransports:
    mywebservice-transport:
      insecureSkipVerify: true
      disableHTTP2: true
      serverName: "myinternwebservice.local"

Unfortunately it does not work. It is still redirected on the web service, where of course the directory does not exist. There is also no error message.
I used PathPrefix because I understood that you don't have to use regular expressions to forward all the following characters to pgadmin.
Where have I done something wrong here?

Many thanks
Sven

Sometime the application will have to have some configuration for a path prefix.

You can try adding the stripPrefix middleware to the router. Some applications will work with just this.

Check the forum here and see if anyone else has posted a configuration with pgadmin and a PathPrefix router.

I think your priorities are vice-verca:
https://doc.traefik.io/traefik/routing/routers/#priority

"To avoid path overlap, routes are sorted, by default, in descending order using rules length."

So your mywebservice-router-https router is picked even if the PathPrefix is /pgadmin.

You could omit the priority value on both routers to fix this (by default the priority is the amount of characters of the rule)

Not my question, but thanks for the long answer!

I didn't know and was already wondering how it works :smile: