Moving off ingress-nginx to Traefik? Your login redirect may point at svc.cluster.local
Sai Pisey3 min readTraefik · ingress-nginx · Kubernetes
In short
- Traefik's kubernetesIngressNGINX provider lets you keep your ingress-nginx annotations. In v3.7.0 to v3.7.19, an Ingress with auth-url, auth-signin and upstream-vhost together sent logged-out users to the internal service name, like https://web.application.svc.cluster.local/oauth2/start.
- The upstream-vhost middleware ran before the auth middleware, so $host in auth-signin and the X-Forwarded-Host sent to your auth server both read the rewritten host. In ingress-nginx, upstream-vhost only touches the request to the backend.
- It's fixed in Traefik v3.7.20 and v3.8.0. On older versions, hardcode the public host in auth-signin and keep an explicit rd, or drop upstream-vhost.
With ingress-nginx no longer maintained, plenty of teams are moving to Traefik. Its kubernetesIngressNGINX provider is the easy path: it reads your existing nginx.ingress.kubernetes.io/* annotations, so in theory you change the controller and leave the Ingress objects alone.
In August someone did exactly that on AKS, running Traefik v3.7.1 next to ingress-nginx and pointing a test request at it. One Ingress had oauth2-proxy in front of a dashboard, with these three annotations:
nginx.ingress.kubernetes.io/auth-url: "http://oauth-proxy.infrastructure.svc.cluster.local:4180/oauth2/auth"
nginx.ingress.kubernetes.io/auth-signin: "https://$host/oauth2/start?rd=$escaped_request_uri"
nginx.ingress.kubernetes.io/upstream-vhost: "$service_name.$namespace.svc.cluster.local:8084"ingress-nginx sent logged-out users to https://dashboard.example.internal/oauth2/start. Traefik sent them to https://web.application.svc.cluster.local/oauth2/start, a name that only resolves inside the cluster. Login was broken for everyone outside it.
They opened traefik/traefik#13680 with the repro and two A/B tests that narrowed it down to upstream-vhost. I sent the fix, #13787. It shipped in Traefik v3.7.20 and v3.8.0 on 23 November 2026.
What you see
I rebuilt the reporter's setup on a kind cluster, with a stub auth server that always returns 401, and sent the same request to v3.7.19 and v3.7.20:
curl -skI https://dashboard.example.internal/private | grep -i location
v3.7.19 location: https://web.application.svc.cluster.local/oauth2/start?rd=%2Fprivate
v3.7.20 location: https://dashboard.example.internal/oauth2/start?rd=%2Fprivaterequest
GET https://dashboard.example.internal/privateIf you're already signed in, you never see the sign-in redirect. It only shows up for someone who isn't, like a new user or an expired session, which makes it easy to miss in a quick migration test.
Why it happened
The provider turns each annotation into a Traefik middleware and chains them on the router. upstream-vhost becomes a middleware that overwrites req.Host. auth-url and auth-signin become the auth middleware, which calls your auth server and, on a 401, builds the redirect by filling in $host from the request.
In v3.7.19 the chain was built with the vhost middleware first:
// translator.go, applyMiddlewares, v3.7.19
if loc.UpstreamVhost != nil {
name := routerKey + "-vhost"
conf.HTTP.Middlewares[name] = &dynamic.Middleware{UpstreamVHost: loc.UpstreamVhost}
rt.Middlewares = append(rt.Middlewares, name)
}
// ... rate limits, connection limits, custom headers ...
// ... then the auth snippet (auth-url, auth-signin)So by the time the auth middleware ran, the request's host was already web.application.svc.cluster.local:8084. $host in the sign-in URL picked that up.
v3.7.0 to v3.7.19
v3.7.20 and v3.8.0
That isn't what ingress-nginx does. There, upstream-vhost is just proxy_set_header Host on the location that proxies to the backend. The auth subrequest and the sign-in redirect are built from the client's own host header, so they never see the rewrite.
Your auth server sees it too
The redirect isn't the only thing that reads the host. The auth middleware also sends X-Forwarded-Host to your auth server. I swapped the stub for an echo server that returns 200 and logged what it received:
On v3.7.19 your auth server is told the request was for web.application.svc.cluster.local:8084. If it builds redirects or applies rules based on the forwarded host, it's working with the wrong name. The backend gets the rewritten host in both versions, which is the whole point of upstream-vhost.
This isn't a way around authentication. The auth server is still called on every request and a 401 still stops it. The internal service name does leak into the redirect, and the port too when Traefik builds the default rd.
The fix
The PR moves the vhost middleware to after the auth middleware, still before retry and the backend:
// Apply upstream-vhost after auth so auth-signin uses the original request host.
if loc.UpstreamVhost != nil {
name := routerKey + "-vhost"
conf.HTTP.Middlewares[name] = &dynamic.Middleware{UpstreamVHost: loc.UpstreamVhost}
rt.Middlewares = append(rt.Middlewares, name)
}I added a test that the vhost middleware comes after the auth snippet in the chain. A Traefik reviewer added a second one that runs the real auth and vhost middlewares together, checking both cases: a 401 redirects to the original host, and a 200 reaches the backend with the upstream host.
Am I affected?
You need Traefik v3.7.0 to v3.7.19 with the kubernetesIngressNGINX provider, and an Ingress with upstream-vhost. Then:
- The broken redirect needs
auth-signintoo, along withauth-url. - The wrong
X-Forwarded-Hostonly needs external auth:auth-urlon the Ingress, or the provider'sglobalAuthURL. $hostinauth-urlitself, or in a configuration or server snippet, also reads the rewritten host.
basic-auth and digest-auth always ran before the vhost middleware, so they were never affected.
To find Ingresses with both annotations (if you use globalAuthURL, every Ingress with upstream-vhost counts):
kubectl get ingress -A -o json | jq -r '.items[]
| select(.metadata.annotations["nginx.ingress.kubernetes.io/upstream-vhost"]
and .metadata.annotations["nginx.ingress.kubernetes.io/auth-url"])
| "\(.metadata.namespace)/\(.metadata.name)"'Then send a logged-out request and look at the redirect:
curl -skI --resolve app.example.com:443:<traefik-ip> https://app.example.com/ | grep -i locationIf it contains svc.cluster.local, you have it.
If you can't upgrade yet
Upgrading to v3.7.20 or v3.8.0 is the real fix. Until then, I tested two workarounds on v3.7.19:
- Hardcode the public host in
auth-signinand keeprd=$escaped_request_uri. The redirect is correct. Your auth server still gets the wrongX-Forwarded-Host, though. - Drop
upstream-vhostif your backend doesn't really need a specific Host header. Both the redirect and the auth server see the right host.
Don't also remove rd. If you hardcode the host and also remove rd from auth-signin, Traefik adds a default rd built from the request host. On v3.7.19 that default points back at https://web.application.svc.cluster.local:8084/private, so users sign in and get sent somewhere they can't reach. Keep the explicit rd.
The report that started this is traefik/traefik#13680, and the fix is #13787.