Search code examples
kubernetestraefiktraefik-ingress

How to use forwardAuth with internal service in Traefik?


Traefik allows to specify a middleware to authenticate each request using forwardAuth, in the documentation it specifies to use an external provider.

# Forward authentication to example.com
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: test-auth
spec:
  forwardAuth:
    address: https://example.com/auth  👈

I have an auth server running inside my k8 cluster itself which I want to use instead on an external service, is there a way to use forwardAuth to point to internal service?


Solution

  • I used K8 Fully Qualified Domain Name as the address for this to work:

    service-name.namespace.svc.cluster.local.