Traefik v3 - Redirect to externalName host drops full url path

Hello everyone,

I am looking into migrating from ingress-nginx to traefik-v3 using kubernetes-crd provider as we have quite some requirements. At first sight, I thought traefik would be a suitable replacement but I am facing quite a lot of issues implementing what seems like “basic“ functionality from ingress-nginx.

In my setup I have an application that calls itself on its own domain on a specific prefixed path. The goal here is to let the “controller” strip the prefix and redirect the remaining path to a separate host. (I know this should just be solved in the application itself but currently this is not an option)

e.g.

https://colin.walker/admin/api/token

should be redirected to

https://admin.colin.walker/api/token

I managed to deploy the following traefik resources;

apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: proxy-admin-page
  namespace: default
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`colin.walker`) && PathPrefix(`/admin`)
      kind: Rule
      services:
        - name: external-admin-page
          port: 443
  tls:
    secretName: default-tls

Alongside;
apiVersion: v1
kind: Service
metadata:
name: external-admin-page
namespace: default
spec:
type: ExternalName
externalName: admin.colin.walker
ports:
- port: 443
targetPort: 443

I did not even implement the removal of /admin in the path yet, it just drops the whole path regardless and sends a request to https://admin.colin.walker:443 when using the external-name reference. Am I attempting something that is inherently not possible with Traefik ?

Kind regards,
Colin Walker

Managed to get a workaround using the following; This now preserves the path that has been provided in the original request but, does not yet forward / keep all original headers.

apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
  name: redirect-admin
  namespace: default
spec:
  redirectRegex:
    regex: ^https://colin.walker/(.*)
    replacement: https://admin.colin.walker/${1}
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
  name: strip-admin
  namespace: default
spec:
  stripPrefix:
    prefixes:
      - "/admin"
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: proxy-admin
  namespace: default
spec:
  entryPoints:
    - websecure
  routes:
    - match: Host(`colin.walker`) && PathPrefix(`/admin`)
      kind: Rule
      middlewares:
        - name: strip-admin
        - name: redirect-admin
      services:
        - name: placeholder-svc
          port: 8080
  tls:
    secretName: default-tls