We use serveral Apache servers as reverse proxy in front of numerous backend servers. The backend servers send a HTTP response header ("Cast") which contains an internal name of the backend server.
In the reverse proxy I would like to log the content of the backend server's response header and prevent the header from being sent to the client.
Logging the header is simple with inserting %{Cast}o
in our custom LogFormat
configuration.
Also, preventing the header from being sent to the client is easy, by using Header unset Cast
The only problem is that when unsetting the header it cannot be logged anymore.
Is there a way to store the backend's response header in a variable, unset the header and log the variable?
Notes
- The Apache servers being used as reverse proxies are Apache 2.2 on RHEL 6 and 2.4 on RHEL7
- Reverse proxy rules use either
ProxyPass
orRewriteRule ... [P]
Best Answer
In the past I have used a intermediate VirtualHost entry as a work-around for similar situations when certain directives didn't play well together:
Your current configuration may look like:
Modify that to point to the intermediate virtual host and strip your header from the responses:
and a new virtual host where you can still log your Cast headers: