title: How to strip the path prefix in Kubernetes Traefik ingress?
body: <p>I'm using k3s v1.22.7 on Ubuntu 20.04. I want <code>/bar/xyz</code> to be <code>/xyz</code> to the pods. Without the middleware I'm properly routed to the pods, with it I get <code>404</code> from Traefik as though the stripping from <code>replacePathRegex</code>/<code>stripPrefix</code> happens before the Ingress path evaluation. Examples online all have it like that though...</p>
  <pre class="lang-yaml prettyprint-override"><code>apiVersion: traefik.containo.us/v1alpha1
  kind: Middleware
  metadata:
    name: strip-prefix
  spec:
    #replacePathRegex:
    #  regex: ^/(?:[^/]+)/(.*)
    #  replacement: /$1
    stripPrefix:
      prefixes:
        - /bar
        - /baz
  ---
  apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    name: foo-ingress
    annotations:
      kubernetes.io/ingress.class: traefik
      traefik.ingress.kubernetes.io/router.middlewares: strip-prefix@kubernetescrd
  spec:
    rules:
    - host: example.org
      http:
        paths:
        - path: /bar
          pathType: Prefix
          backend:
            service:
              name: foo-service
              port:
                number: 5001
        - path: /baz
          pathType: Prefix
          backend:
            service:
              name: foo-service
              port:
                number: 5002
  </code></pre>