HostRegexp, v3 and named regexp

Hi,

I used to have a router used to redirect all traffic to https and used named regexp:

      - "traefik.http.routers.http-catchall.rule=HostRegexp(`{host:.+}`)"
      - "traefik.http.routers.http-catchall.entrypoints=web"
      - "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"

In v3 I had to use the simple regexp:

    - "traefik.http.routers.http-catchall.rule=HostRegexp(`.+`)"

that happens not to work on v2+.
I noticed in the migration docs that now these regexp must follow go syntax, but I thought that named regexp where go regexp syntax as well... since I'm not a golang savvy, I'd like to know when named regexp are needed and when they are not needed and not even usable.

TIA

2 Likes

named regexp are never really usable: the v2 syntax (HostRegexp({host:.+})) was just a way to isolate the regexp part, the name is not usable.

The "pure" regexp (HostRegexp(`.+`)) is only available in v3 and NOT available in v2.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.