Routing certain Paths to different Docker containers

I have a server which we use to publish our products using docker containers and Traefik reverse proxy server

The new “Frontend” of our application is defined using the following information:


services:
  frontend:
    image: \*\*\*
    restart: unless-stopped
    expose:
      - 3000
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=web"
      - "traefik.http.routers.new-frontend.rule=Host(`asd.com`,`www.asd.com`)"
      - "traefik.http.routers.new-frontend.entrypoints=websecure"
      - "traefik.http.routers.new-frontend.tls.certresolver=letsencrypt"
      - "traefik.http.routers.new-frontend.priority=1"
      - "traefik.http.services.new-frontend.loadbalancer.server.port=3000"
   networks:
    - web

networks:
  web:
     external: true

While the old frontend:

version: '3.8'

services:
  next:
    image: *****
    networks:
      - web
    expose:
      - 3000
    platform: linux/amd64
    deploy:
      mode: replicated
      replicas: 1
    restart: unless-stopped


    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=web"
      - "traefik.http.routers.old-frontend-subpaths.rule=Host(`asd.com`, `www.asd.com`) && (PathPrefix(`/blog`) || PathPrefix(`/community`))"
      - "traefik.http.routers.old-frontend-subpaths.entrypoints=websecure"
      - "traefik.http.routers.old-frontend-subpaths.tls.certresolver=letsencrypt"
      - "traefik.http.routers.old-frontend-subpaths.priority=100"
      - "traefik.http.services.old-frontend-subpaths.loadbalancer.server.port=3000"
      - "traefik.http.routers.old-frontend-subpaths.middlewares=strip-subpaths"
      - "traefik.http.middlewares.strip-subpaths.stripprefix.prefixes=/blog,/community"

networks:
  web:
    external: true

What I want is to route asd.com/blog and asd.com/community to the old frontend while maintaing the URL (the strip part should be removed)

How to do so?

( Host(`asd.com`) || Host(`www.asd.com`) ) && ( PathPrefix(`/blog`) || PathPrefix(`/community`) )

Use correct rule and remove middleware declaration and it’s assignment to router.

Note that double-host is old notation, newer Traefik needs it separated as shown above.

Host(`asd.com`,`www.asd.com`)

And you don’t need any priority, as the longer rule, which is usually more specific, has higher priority and will be tested first.