Use regexp named variable for routing

Hello folks,

I have following requirements and want to solve it by using Traefik.

Sorry if I missed any existing topics when searching, but the only result I found on stackoverflow does not work. AFAIK, replacepathregex uses only path for regex matching, not full URL.

Any help would be appreciated.

My expectation is something similar to this (but middlewares and/or other k8s CRDs can be used also):

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: domain2-forwarder
spec:
  entryPoints:
    - web
    - websecure
  routes:
  - kind: Rule
    match: HostRegexp(`{subdomain:[^\.]*}\.domain1.com`)
    servers:
      server1:
        url: https://domain2.com/prefix-$subdomain/