Forum Discussion

Awkrd1_7470's avatar
Awkrd1_7470
Icon for Nimbostratus rankNimbostratus
Feb 23, 2012

Unable to identify HTTP header variable for pool redirection

I have a two tier load balancing scenario where my client is accessing a load balanced SOA environment which I'll call my "upper load balance tier". The upper load balance tier accesses a VIP on the "lower load balance tier" where we load balance between two shopping sites. I need to provide a method for the client to return to the same data center. Since this is web content I don't have an application to insert a session id, or any other unique identifier so I can provide "persistence".The application team decided to insert a header "datacenter" with a variable "01" or "02" for datacenter identification and "persistence". I've verified the header "datacenter" exist in the subsequent request from the client but I can't get the i-Rule to identify the header, responds with an error. Please look at the rule and see what I have overlooked. Thanks!

 

 

when HTTP_RESPONSE{

 

 

if { [HTTP::header "datacenter"] equals "01" } {

 

log local0. "datacenter is $HTTP::header value"

 

pool DATACENTER-01

 

} elseif { [HTTP::header "datacenter"] equals "02" } {

 

log local0. "datacenter is $HTTP::header value"

 

pool DATACENTER-02

 

} else {

 

pool DATACENTER01-02

 

}

 

 

}

 

 

Error response: Feb 23 13:19:33 tmm tmm[1867]: 01220001:3: TCL error: PROD-ITA-9045-SELECT-POOL-ON-HTTP-HOST-HEADER-VALUE-20 - can't read "HTTP::header": no such variable while executing "log local0. "datacenter is $HTTP::header"" Thanks!
  • Try replacing $HTTP::header value with [HTTP::header "datacenter"].

     

     

    But what are you actually trying to accomplish? A pool and pool member selection has already been made by the time the HTTP_RESPONSE event has been triggered. Is the datacenter header inserted by the client in requests or the server in responses? What do you want to do when you see this header?

     

     

    Aaron
  • Correct...It should have been on the HTTP_REQUEST. I need to load balance the initial client request, which would not have the HTTP header "datacenter" present. The server inserts the HTTP header "datacenter" 01 or 02 in the response for the client's subsequent request to be used by the i-Rule and returned to the same data center. I modified the rule to add logging;

     

     

    when HTTP_REQUEST {

     

    set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]"

     

    log local0. "============================================="

     

    log local0. "$LogString (request)"

     

    foreach aHeader [HTTP::header names] {

     

    log local0. "$aHeader: [HTTP::header value $aHeader]"

     

    }

     

    log local0. "============================================="

     

     

    if { [HTTP::header "datacenter"] eq "01" } {

     

    pool PROD-ITA-9045-BILLERICA

     

    log local0. "$HTTP::header"

     

    } elseif { [HTTP::header "datacenter"] eq "02" } {

     

    pool PROD-ITA-9045-WINNIPEG

     

    log local0. "$HTTP::header"

     

    } else {

     

    pool PROD-ITA-9045

     

    }

     

    }

     

     

    I think it may be working but I am only directed to datacenter-01, which may be a limitation of my SOAPUI client.

     

     

    Could I not simplify this using universal persistence and a simple i-Rule?

     

    when HTTP_REQUEST {

     

    persist uie [HTTP::header datacenter]

     

    }

     

     

     

  • Ran some test this morning and used the following rule which is actually working. Thanks!

     

     

    when HTTP_REQUEST {

     

    set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]"

     

    log local0. "============================================="

     

    log local0. "$LogString (request)"

     

    foreach aHeader [HTTP::header names] {

     

    log local0. "$aHeader: [HTTP::header value $aHeader]"

     

    }

     

    log local0. "============================================="

     

     

    if { [HTTP::header "datacenter"] eq "01" } {

     

    pool PROD-ITA-9045-BILLERICA

     

    log local0. "$HTTP::header"

     

    } elseif { [HTTP::header "datacenter"] eq "02" } {

     

    pool PROD-ITA-9045-WINNIPEG

     

    log local0. "$HTTP::header"

     

    } else {

     

    pool PROD-ITA-9045

     

    }

     

    }