Remove header before forward request to proxy

Hello,

is it possible to remove header from incoming request before pass it to the configured proxy ? By example, I would like to discard the header “X-SSLClient-DN” cause this header must be only set by Caddy and not by the incoming request.

Thanks

Easily done - check out the proxy docs. You’re looking for the header_upstream subdirective.

By default, existing header fields will be replaced, but you can add/merge field values by prefixing the field name with a plus sign (+). You can remove fields by prefixing the header name with a minus sign (-) and leaving the value blank.

So a proxy that removes the existing header entirely would look something like this:

proxy / backend:8080 {
  ...
  header_upstream -X-SSLClient-DN
}

If you want to configure Caddy to replace this header, you wouldn’t use a plus or a minus, instead you’d just set it - for example, header_upstream X-SSLClient-DN some_value.

1 Like

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