/Hydrate Headers

Hydrate Headers

2
v0.4.0

traefik-hydrate-headers

Hydrate headers from remote endpoint

Configuration

KeyTypeRequiredDefaultDescription
appendOn.statusCodes[]intRemote status codes at which headers will be appended
fetchOn.cookies[]stringOnly fetch remote when any of cookies from this list present in original request
fetchOn.headers[]stringOnly fetch remote when any of headers from this list present in original request
fetchOn.orboolfalseWhen both fetchOn.cookies and fetchOn.headers conditions are present, evaluate them as OR (by default as AND)
forwardHeaders[]stringList of headers from original request to be passed to remote
headersmap[string]string:white_check_mark:Map of headers in which to set remote response (key is header name, value is Go template)
nextOn.statusCodes[]intRemote status codes at which next middleware will be called
remote.methodstringGETRequest method
remote.urlstring:white_check_mark:Url to be fetched
statusCodeErrorint503Status code sent to client on nextOn conditions failure

Headers template examples

Set remote body to request header

X-Example: '{{ .RemoteBody }}'

Unmarshal JSON body and set field to header

X-User-Id: |
{{ $user := unmarshalJson .RemoteBody }}
{{ $user.id }}

Set remote header value to request header

X-Example: '{{ .RemoteResponse.Header.Get "X-Remote-Header" }}'

Set original request header value to another request header

X-Real-Ip: '{{ .Request.Header.Get "Cf-Connecting-Ip" }}'