Simple Reverse Proxy throwing a 401

        http:
          middlewares:
            my-node-prefix:
              replacePath:
                path: '/{{ env "MY_KEY" }}'
            autodetect:
              contentType:
                autoDetect: true
          routers:
            my-node:
              middlewares:
              - autodetect
              - my-node-prefix
              entryPoints:
              - mine
              rule: Host(`traefik.base.svc.cluster.local`)
              service: mine
          services:
            mine:
              loadBalancer:
                healthCheck:
                  path: '{{ env "MY_KEY" }}/health'
                  interval: 60s
                  timeout: 3s
                servers:
                - url: https://my-node.goes.here.com

I've been trying to setup a simple reverse proxy where a request comes into traefik from within the kubernetes cluster to: http://traefik.< my-namespace >.svc.cluster.local:8080 or even http://traefik.< my-namespace >.svc.cluster.local/mine but I'm getting a 401 response.

I need Traefik to add a URI of "/${MY_KEY}", because this is how the upstream server requires auth.

I think the healthcheck is working because the logs show: {"level":"debug","msg":"Routine health check refresh for backend: mine@file","time":"2024-01-17T07:05:00Z"}

What am I doing wrong here?

It seems you are using your env var twice and one time you prefix with /. Which one is right?

Maybe replace your target service with whoami for testing.

Turns out forwarding the host header is turned on by default: Traefik Services Documentation - Traefik

So, when a request was coming in to http://traefik.base.svc.cluster.local, it was failing the upstream because thats not the host I was trying to reach...

Setting passHostHeader: false solved my issue.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.