Need a little help understanding priorities for rules

I am running into an issue getting priorities to work the way I think I understand them from the docs

Based on the compose file below, I would expect beta.mainsite.home.local to ALWAYS be selected when accessing it via https://beta.mainsite.home.local -- that doesn't seem to be the case though as the mainsite.home.local router is what is being matched.

I have tried setting the priority to > 1024 and tried setting it to 1 and neither seems to have any effect. So am I misunderstanding how priority works?

version: "3.7"

services:

  wordpress-betasite:
    # https://hub.docker.com/_/wordpress
    container_name: wordpress-betasite
    image: wordpress
    env_file: 
      - .env
      - .env.wordpress-betasite
    volumes:
      - ./data/site:/config:rw 
      - ./data/wwwroot:/var/www/html:rw 
    networks:
      - web 
      - data 
    depends_on:
      - wordpress-betasite-tools
    security_opt:
      - no-new-privileges:true
    labels:
      - "com.centurylinklabs.watchtower.enable=false"
      - "traefik.enable=true"
      - "traefik.docker.network=web"
          
      # wordpress-betasite: websecure
      - "traefik.http.routers.wordpress-betasite.entrypoints=websecure"
      - "traefik.http.routers.wordpress-betasite.service=wordpress-betasite"
      - "traefik.http.services.wordpress-betasite.loadbalancer.server.port=80"
      - "traefik.http.routers.wordpress-betasite.priority=300"
      - "traefik.http.routers.wordpress-betasite.rule=(Host(`beta.mainsite.home.local`) || HostRegexp(`{subhost:[a-zA-Z0-9-]+}.beta.mainsite.home.local`))"
      - "traefik.http.services.wordpress-betasite.loadbalancer.server.scheme=http"
      - "traefik.http.routers.wordpress-betasite.tls=true"
    restart: unless-stopped

  wordpress-mainsite:
    # https://hub.docker.com/_/wordpress
    container_name: wordpress-mainsite
    image: wordpress
    env_file: 
      - .env
      - .env.wordpress-mainsite
    volumes:
      - ./data/site:/config:rw 
      - ./data/wwwroot:/var/www/html:rw 
    networks:
      - web 
      - data 
    depends_on:
      - wordpress-mainsite-tools
    security_opt:
      - no-new-privileges:true
    labels:
      - "com.centurylinklabs.watchtower.enable=false"
      - "traefik.enable=true"
      - "traefik.docker.network=web"
          
      # wordpress-mainsite: websecure
      - "traefik.http.routers.wordpress-mainsite.entrypoints=websecure"
      - "traefik.http.routers.wordpress-mainsite.service=wordpress-mainsite"
      - "traefik.http.services.wordpress-mainsite.loadbalancer.server.port=80"
      - "traefik.http.routers.wordpress-mainsite.priority=100"
      - "traefik.http.routers.wordpress-mainsite.rule=(Host(`mainsite.home.local`) || HostRegexp(`{subhost:[a-zA-Z0-9-]+}.mainsite.home.local`))"
      - "traefik.http.services.wordpress-mainsite.loadbalancer.server.scheme=http"
      - "traefik.http.routers.wordpress-mainsite.tls=true"
    restart: unless-stopped


networks:
  web:
    external: true
  data:
    external: true

Hello @ravensorb,

Is it your real configuration?

- "traefik.http.routers.wordpress-betasite.rule=(Host(`mainsite.home.local`) || HostRegexp(`{subhost:[a-zA-Z0-9-]+}.mainsite.home.local`))"

IT seems that there is a typo, you want to define the rule for the mainsite instead of the betasite:

- "traefik.http.routers.wordpress-mainsite.rule=(Host(`mainsite.home.local`) || HostRegexp(`{subhost:[a-zA-Z0-9-]+}.mainsite.home.local`))"

It was a typo -- thanks.

I wonder if there is a way to see the calculated priority for all of the rules?

I'm glad to know that your issue is resolved, could you set this thread as resolved accordingly ?

Concerning the priority, I answered in the other thread :wink:

I mean it was a typo in the post :slight_smile: In my actual config -- the issue still seems to be happening. For some reason I cannot change the order of these two rules no matter what I do.

Oops! sorry :stuck_out_tongue:
Could you share your Traefik logs from the begining?