Forum Discussion

Bruno_102975's avatar
Bruno_102975
Icon for Nimbostratus rankNimbostratus
Dec 23, 2008

HTTP Redirect after LB_Select

Hello,

 

I need to do a HTTP Redirect of the client request to the 'elected' node of a set of pools.

 

The selection of the Pool based on the client source IP works fine

 

The selection in the pool and redirection work fine

 

The one after the other cannot work "LB_SELECTED is not valid in current event context"

 

Could you pls suggest another way to do it?...

 

 

when HTTP_REQUEST {

 

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

 

{ pool Pool_AutoconfUK

 

}

 

else

 

{ pool Pool_AutoconfEUA

 

}

 

}

 

when LB_SELECTED {

 

if {[LB::server addr] equals "10.64.21.157"} {

 

HTTP::redirect http://10.64.21.157

 

} else {

 

HTTP::redirect http://10.64.17.123

 

}

 

}

 

}

2 Replies

  • Hi Bruno,

     

     

    Check this post for a possible solution (Click here). Basically, you can force a load balancing selection in HTTP_REQUEST using LB::select and then send a redirect based on the selected pool member address.

     

     

    Also, you can use IP::addr (Click here) to compare single IP addresses or subnets more efficiently than a string comparison.

     

     

    Aaron
  • Hello,

     

    Sorry for this late reply

     

    It seems to work fine first shot. I followed both advices

     

    Thanks a lot for your fast reply and have a great new year!