How to add prefix (docker swarm mode)

So I have been playing around with this for a while now with AI and I am unable to get it working.I have two sites, aaa.com and bbb.com, they both come from a single springboot service, let’s say service:9000, and aaa.com maps to service:9000 and bbb.com maps to service:9000/bbb/, So I have configured the basic route and it works, bbb.com and aaa.com both serves the content from service:9000, so my spring boot config and everything works.However my end goal is to have bbb.com maps to service:9000/bbb/. The first thing come to my mind is addPrefix middleware. Google’s AI suggested this:

- "traefik.http.routers.bbb-all.middlewares=bbb-add-prefix@docker"
- "traefik.http.middlewares.bbb-add-prefix.addprefix.prefix=/bbb/"

Unfortunately, this is not working, it always end up with 404. Turned on DEBUG and access log, I see the requstPath is / in access log (maybe that was before middleware is added)? and do not see any log from log.txt when I access bbb.com

So what I am doing wrong?
Thanks

Works for me:

services:
  whoami:
    image: traefik/whoami:v1.11.0
    hostname: whoami
    networks:
      - proxy
    labels:
      - traefik.enable=true
      - traefik.http.routers.mywhoami.rule=Host(`whoami.example.com`)
      - traefik.http.routers.mywhoami-2.rule=Host(`whoami-2.example.com`)
      - traefik.http.routers.mywhoami-2.middlewares=myPrefix
      - traefik.http.middlewares.myPrefix.addprefix.prefix=/bbb
      - traefik.http.services.mywhoami.loadbalancer.server.port=80

Maybe the issue is the additional / in your addprefix.

Test by replacing your image with whoami, which echos all request variables.

Thanks, I also tried without trailing / (just /bbb) still not working.
I will give whoami a try. Also, for your config, you did not use @doceker. So your whoami is not running in container? or I should remove @docker?

Thanks again

If it's declared in the labels of a container, Traefik will default to @docker.

I checked the result with whoami container, whoami-2.example.com/ will arrive at service as whoami-2.example.com/bbb/

Thanks! I think it is traefik version

my config works in 3.4.5 but not in 3.5.1

Any breaking changes could have caused this issue?

In 3.4.5 I see my routers in dashboard, in 3.5.1 I don’t see my routers in dashboard

Maybe check the migration doc.

Yea, checked the migration doc, did not see any breaking changes.