How to add custom apache2/httpd header based on BALANCER_WORKER_ROUTE variable?

13 Views Asked by At

I have a very simple httpd apache2 setup, and would like to set a custom header only if the route=green BalancerMember is active and chosen for the request.

The following does not work:

<VirtualHost *:80>
        ProxyPass / balancer://cluster/
        ProxyPassReverse / balancer://cluster/

        <If "%{BALANCER_WORKER_ROUTE} == 'green'">
            Header add X-Custom-Header "green is active"
        </If>

         <Proxy balancer://cluster>
            BalancerMember http://localhost:8088 route=blue  loadfactor=10
            BalancerMember http://localhost:8089 route=green loadfactor=1
        </Proxy>
</VirtualHost>

It gives: Cannot parse condition clause: Variable 'BALANCER_WORKER_ROUTE' does not exist.

Which is strange, because if I add the route just always to the response header without a condition, it works: Header add X-Balancer-Route "%{BALANCER_WORKER_ROUTE}e"

What are my chances? Is that possible with a condition at all? My goal is to only mark the green instance somehow in the response.

0

There are 0 best solutions below