Combining Traefik frontend redirect replacement with PathPrefixStrip

admin

Administrator
Staff member
I am encountering some conflicts between the
Code:
traefik.frontend.redirect
and
Code:
PathPrefixStrip
. the
Code:
docker-compose.yml
file below always routes
Code:
www.mysite.nl/adminer
to the wordpress container. If I omit the redirect rules it works correctly and i get routed to the adminer instance. How can I make these rules work together?

Drilled down
Code:
docker-comose.yml
:

Code:
version: '3'
services:
  wordpress:
    image: wordpress:latest 
    restart: $RESTART
    container_name: ${COMPOSE_PROJECT_NAME}_wp
    depends_on:
      - mysql
    networks:
      - web
    labels:
      - 'traefik.backend=$COMPOSE_PROJECT_NAME'
      - 'traefik.entrypoint=https'
      - 'traefik.enable=true'
      - 'traefik.frontend.rule=Host:mysite.nl, www.mysite.nl, cdn.mysite.net'
       # omitting these rules make the adminer instance reachable
      - 'traefik.frontend.redirect.regex=^https?://mysite.nl/(.*)'
      - 'traefik.frontend.redirect.replacement=https://www.mysite.nl/$${1}'
  mysql:
    image: mysql:latest
    restart: $RESTART
    container_name: ${COMPOSE_PROJECT_NAME}_db
    networks:
      - web
  adminer:
    image: adminer:4.6.2
    restart: $RESTART
    container_name: ${COMPOSE_PROJECT_NAME}
    depends_on:
      - mysql
    networks:
      - web
    labels:
      - 'traefik.backend=${COMPOSE_PROJECT_NAME}_adminer'
      - 'traefik.entrypoint=https'
      - 'traefik.enable=true'
      - 'traefik.frontend.rule=Host:www.mysite.nl;PathPrefixStrip:/adminer'

networks:
  web:
    external:
      name: traefik_${COMPOSE_PROJECT_NAME}_web