# Need a little help understanding priorities for rules

**URL:** <https://community.traefik.io/t/need-a-little-help-understanding-priorities-for-rules/9245>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [January 7, 2021, 10:17pm UTC](https://community.traefik.io/t/need-a-little-help-understanding-priorities-for-rules/9245 "2021-01-07T22:17:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ravensorb](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ravensorb/32/2053_2.png) [@ravensorb](https://community.traefik.io/u/ravensorb)\
**Post date:** [January 7, 2021, 10:17pm UTC](https://community.traefik.io/t/need-a-little-help-understanding-priorities-for-rules/9245/1 "2021-01-07T22:17:54Z")

</div>

I am running into an issue getting priorities to work the way I think I understand them from [the docs](https://doc.traefik.io/traefik/v2.3/routing/routers/#priority)

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](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?

```auto
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

```

---

<div class="post-metadata">

**Author:** ![jbd](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/jbd/32/341_2.png) [@jbd](https://community.traefik.io/u/jbd)\
**Post date:** [January 8, 2021, 8:58am UTC](https://community.traefik.io/t/need-a-little-help-understanding-priorities-for-rules/9245/2 "2021-01-08T08:58:52Z")

</div>

Hello @ravensorb,

Is it your real configuration?

```auto
- "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:

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

```

---

<div class="post-metadata">

**Author:** ![ravensorb](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ravensorb/32/2053_2.png) [@ravensorb](https://community.traefik.io/u/ravensorb)\
**Post date:** [January 8, 2021, 11:18am UTC](https://community.traefik.io/t/need-a-little-help-understanding-priorities-for-rules/9245/3 "2021-01-08T11:18:20Z")

</div>

It was a typo -- thanks.

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

---

<div class="post-metadata">

**Author:** ![jbd](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/jbd/32/341_2.png) [@jbd](https://community.traefik.io/u/jbd)\
**Post date:** [January 8, 2021, 11:21am UTC](https://community.traefik.io/t/need-a-little-help-understanding-priorities-for-rules/9245/4 "2021-01-08T11:21:35Z")

</div>

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 😉

---

<div class="post-metadata">

**Author:** ![ravensorb](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ravensorb/32/2053_2.png) [@ravensorb](https://community.traefik.io/u/ravensorb)\
**Post date:** [January 8, 2021, 12:59pm UTC](https://community.traefik.io/t/need-a-little-help-understanding-priorities-for-rules/9245/5 "2021-01-08T12:59:27Z")

</div>

I mean it was a typo in the post 🙂 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.

---

<div class="post-metadata">

**Author:** ![jbd](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/jbd/32/341_2.png) [@jbd](https://community.traefik.io/u/jbd)\
**Post date:** [January 8, 2021, 1:07pm UTC](https://community.traefik.io/t/need-a-little-help-understanding-priorities-for-rules/9245/6 "2021-01-08T13:07:53Z")

</div>

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