[Reverse Proxy] Intercepting responses' headers does not work


1. The problem I’m having:

I cannot get the Response’s Headers in the “Reverse Proxy” block. SOURCE: reverse_proxy (Caddyfile directive) — Caddy Documentation

My config is

reverse_proxy https://commons.wikimedia.org {
          @redirect status 3xx
          handle_response @redirect {
            header +txt {rp.header.location}

2. Error messages and/or full log output:

it returns “{http.reverse_proxy.header.location}”, not the “location” header 's value. I tried {rp.header.*}, then it returns “{rp.header.*}”

If I tried, to use {rp.status_code}, it can return the “301” redirect code.

3. Caddy version:

Caddy 2.6.4

a. System environment:

Kubernetes 1.24

You need to use the canonical form of the header name, i.e. Location, not location.

Thanks @francislavoie

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