Home > Enterprise >  error while parsing rule Host(\\`registry.domain.com\\`): 1:6: illegal character U 005C
error while parsing rule Host(\\`registry.domain.com\\`): 1:6: illegal character U 005C

Time:11-07

I have a Kubernetes Cluster set up. I am trying to set up an IngressRoute for traefik dashboard and I have been following this guide:

https://blog.zachinachshon.com/traefik-ingress/

When I add the IngressRoute and Middleware I get the following errors on the traefik pod:

time="2022-11-05T11:45:52Z" level=error msg="error while parsing rule Host(\\`traefik.domain.com\\`) && (PathPrefix(\\`/api\\`) || PathPrefix(\\`/dashboard\\`)): 1:6: illegal character U 005C '\\' (and 2 more errors)" entryPointName=websecure routerName=traefik-traefik-dashboard-1cd33424d5fb33e10e2e@kubernetescrd
time="2022-11-05T11:45:52Z" level=error msg="invalid rule Host(\\`traefik.domain.com\\`) && (PathPrefix(\\`/api\\`) || PathPrefix(\\`/dashboard\\`)), error: 1:6: illegal character U 005C '\\' (and 2 more errors)" routerName=traefik-traefik-dashboard-1cd33424d5fb33e10e2e@kubernetescrd entryPointName=websecure

I have tried changing the backtick to ' and " and tried adding and removing \ before them with no luck.

yml:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: traefik-dashboard
  namespace: traefik
spec:
  entryPoints:
    - websecure
  routes:
    - kind: Rule
      match: Host(\`traefik.domain.com\`) && (PathPrefix(\`/api\`) || PathPrefix(\`/dashboard\`))
      services:
        - name: api@internal
          kind: TraefikService
      middlewares:
        - name: traefik-dashboard-auth # Referencing the BasicAuth middleware
          namespace: traefik
  tls:
    secretName: domain-com-cert-secret
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: traefik-dashboard-auth
  namespace: traefik
spec:
  basicAuth:
    secret: traefik-dashboard-auth-secret

CodePudding user response:

You need to wrap the entire rule in double quotes as per the documentation.

match: "Host(`traefik.domain.com`) && (PathPrefix(`/api`) || mathPrefix(`/dashboard`))"
  • Related