Is it possible to forward the query parameters when authforward

I am using authForward in traefik 2.10.x to do some token check, this is the middleware config:

apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
  name: jwt-token-auth
  namespace: reddwarf-pro
spec:
  forwardAuth:
    address: >-
      http://dolphin-post-service.reddwarf-pro.svc.cluster.local:11014/post/auth/access_token/verify

when I put the access token in query parameters, the authforward could not forward the query parameters. what should i do to forward the query parameters?(I have to put the access token in parameters becuase the sse and websocket did not support custom headers)

1 Like

The X-Forwarded-Uri header in the ForwardAuth request might include the query. (doc)

I read the doc again and again but did not found the doc mention that the X-Forwarded-Uri enabled will forward the query parameter. I tried:

trustForwardHeader: true

but did not work.

X-Forwarded-Uri header should include the original URL, and a URL usually includes the query string.

It will not add the query parameter of the original request to the ForwardAuth query.

You need to read it from the added header.

works, I enable the trustForwardHeader: true and get the url parameters in server side like this:

String uri = request.getHeader("X-Forwarded-Uri");