0

I want to use HostRegex to forward all matching subdomains to a specific location. This is my dynamic config

http:
  routers:
    my-router:
      entryPoints:
      - web
      - webSecure
      rule: "HostRegexp(`{subdomain:[a-z]+}.test.example.com`)"
      service: my-service
      tls:
        certResolver: zerossl
        domains:
        - main: "test.example.com"
          sans:
          - "*.test.example.com"
  services:
    my-service:
      loadBalancer:
        passHostHeader: true
        servers:
        - url: https://srv-02.int.example.com:8443

But it does not match https://automation.test.example.com.

I had a look into the Traefik sources and put a test next to the existing ones and there it seems to be OK.

If I change my rule to HostRegexp(`automation.test.example.com`) then it does match.

I am using Traefik 3.6.0.

Any ideas?

1 Answer 1

0

I found it: the regex was simplified and the v2 {} syntax is not valid anymore

Changing it to

HostRegexp(\`^.+\\.test\\.example\\.com$\`)`

solves the issue.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.