Hi all,

I am running an apache 2.4.7 on CentOS 6.7

I am trying to perform request routing within a reverse proxy based on the 
x-auth header, but for some reasons the if and elseif statements are alwyas 
evalutaing to true.



Here is the part from the config. This is contained in the virtual host section 
of my config file.


# making sure that the variables do have a default value, if none of the if 
statements are during true then these values should show up

Define ifLocation1 False
Define ifLocation2 False
Define ServerLocation Location-default


<If "%{HTTP:x-auth} -strcmatch 'XXXXXXXX' " >
      Define ServerLocation Location-1
      Define ifLocation1 true
</If>
<ElseIf "%{HTTP:x-auth} =~ m#YYYYYYY#i " >
       Define ServerLocation Location-2
       Define ifLocation2 true
</ElseIf>

I am using strcmatch and =~ for testing purposes to find out which matches my 
needs. what I would actually like to achieve is a check if the token ends with 
with XXXXXXX and then move to Location-1 or with YYYYYY and move to Location-2. 
in all other cases I want to use the default location.

The token we use in the x-auth header do neither contain XXXXXXXX nor YYYYYYY 
so I would expect the Server Location to be "Location-default"
The part I do not understand is why ifLocation1 and ifLocation2 are both set to 
true and the ServerLocation contains the value of the last define statement, 
which is "Location-2"

For logging of the relevant info I am using the following statement

CustomLog ${APACHE_LOG_DIR}/token.log "i:%{x-auth}i o:%{x-auth}o  
decision:${ServerLocation}  Statement1:${ifLocation1} Statement2:${ifLocation2}

For requests that do not contain a token or x-auth header I am getting
i:- o:-  decision:Location-2  Statement1:true Statement2:true

For requests with a token I am getting pretty much the same, jsut with a token 
included

i:itwefq9od2j9r2a0f9tz03djkattwerawg_fddsdwra_wrqs o:-  decision:Location-2  
Statement1:true Statement2:true

I am currently running out of ideas on what I am doing wrong and why the if 
statements always evaluate to true. Any help is appreciated

Thanks

Chris



Reply via email to