I have a server running mod_proxy and I need to essentially rename a request header. A proxy closer to the origin is stripping off the X-Forwarded-For header, but we need that data to persist, so I want to add the value to a different header to allow the origin to pick it up.
From my reading of the doco there is no way to rename a header and I can't see how to pass in values into RequestHeader add in mod_headers.
RequestHeader
can insert values of environment variables into header values, andSetEnvIf
can set environment variables based on request header values, so the following configuration should achieve what you need:You should use
set
instead ofadd
, so that even if a client sends a request containing your custom header, the client-specified value will be overwritten (although even this is not 100% reliable, because theX-Forwarded-For
header could be spoofed too). Also test what happens if a request withoutX-Forwarded-For
is received.