Forum Discussion

njal_67545's avatar
njal_67545
Icon for Nimbostratus rankNimbostratus
Apr 22, 2013

URL balansing, multiple pools in one session

I am trying to do URL loadbalancing over different pools.

 

works nicely - usually.

 

However, when a single webpage (session) has 2 or more GET statements matched by different seach patterns and getting separate backend pools i fails. It will trigger the LB_FAILED event. I have a good test-case and the behaviour is 100% reproducable.

 

Why? Is it something obvious?

 

(I should also mention that I am not very experienced when it comes toi iRules)

 

 

when CLIENTSSL_CLIENTCERT {

 

set cur [SSL::sessionid]

 

set ask [session lookup ssl $cur]

 

if { $ask eq "" } {

 

session add ssl [SSL::sessionid] [SSL::cert 0]

 

}

 

}

 

when HTTP_REQUEST {

 

SSL_CerGlobal

 

set id [SSL::sessionid]

 

set the_cert [session lookup ssl $id]

 

if { $the_cert != ""} {

 

HTTP::header insert X-Client-Cert [X509::whole $the_cert]

 

}

 

SSL disable serverside

 

SSL::disable serverside

 

 

switch -glob [string tolower [HTTP::uri]] {

 

"*string1*" -

 

"*string2*" -

 

"*string3*" {

 

SEARCH-StringSOAP

 

set new_host "xmlgwu:8080"

 

HTTP::header replace Host $new_host

 

pool xmlgwu.-8080

 

}

 

"*string4*" -

 

"*string5*" {

 

SEARCH-StringREST/XML

 

set new_host ":81"

 

HTTP::header replace Host $new_host

 

pool xmlgwu.-81

 

rateclass XML_SOAP_RC

 

}

 

"*string6*" {

 

SEARCH-StringSOAP

 

set new_host "ikko.:7370"

 

HTTP::header replace Host $new_host

 

pool ikko.-7370_2

 

rateclass XML_SOAP_RC

 

}

 

"*string7*" {

 

SEARCH-String

 

set new_host "ikkeno"

 

HTTP::header replace Host $new_host

 

pool ikkeno

 

rateclass IKK_RC

 

}

 

"*string8*" {

 

SEARCH-StringREST/XML

 

set new_host "xmlgwu:81"

 

HTTP::header replace Host $new_host

 

pool xmlgwu.-81

 

rateclass XML_SOAP_RC

 

uri-rewrite

 

HTTP::uri [string range [HTTP::uri] 3 end]

 

}

 

"*string9*" {

 

SEARCH-String

 

HTTP::redirect "https://ikko.com"

 

log local0. "Client: [IP::client_addr] -> HOST:[http_host] + URL:[HTTP::uri]"

 

}

 

"*string10*" {

 

SEARCH-String

 

HTTP::redirect "https://www.string11.string11.com/"

 

log local0. "Client: [IP::client_addr] -> HOST:[http_host] + URL:[HTTP::uri]"

 

}

 

default {

 

SEARCH-StringDEFAULT/WildCard

 

log local0. "default"

 

log local0. "Client: [IP::client_addr] -> HOST:[http_host] + URL:[HTTP::uri]"

 

pool www.443

 

SSL::enable serverside

 

if {[IP::addr [IP::client_addr] equals 138.2.0.0/16] } {

 

snat 12.148.28.40

 

} else {

 

snat 12.148.28.37

 

}

 

}

 

}

 

}

 

 

 

when LB_FAILED {

 

switch [LB::server pool] {

 

default {

 

set ifileContent [ifile get "/Common/iFile-PoolDown.html"]

 

HTTP::respond 503 content $ifileContent

 

unset ifileContent

 

log local0. "Client: [IP::client_addr] -> HOST:[http_host] + URL:[HTTP::uri]"

 

log local0. "[LB::server pool] down"

 

}

 

}

 

set tcplen [TCP::payload length]

 

log local0.debug "CLIENT_DATA ($tcplen)"

 

 

}