Contribute Open Script

forward requests based on URL query degit

by kobayash on ‎07-10-2012 10:04 PM (581 Views)

In some cases, user requests which has url query shoudl forwrad a soecifc server group

For example, the query degit is odd or even.

     Tested with Brocade ServerIron ADX : Yes

     Description (Mandatory)

    

     Correct and check the URL query, it is odd or even.

     Beased on that results, the request forwards the specific servers.

     In case of the request doesn't have specific url query, it forwards entire server group.

Limitations (Optional) : None

Of course, you should modify query name and that query should be number.

(Following script serach "query_id".)

Required environment (Optional) : None

Assume the query length should be 9.

Real server-id s are 1151 1nd 1153.

Real server group is 10, which belongs to all of real servers.

Comments :

In some case, query length will not fix.

In such case, you should modify follwing line.

my $query_id=substr($query,$pointer+9,9);

Source Code

       

use OS_SLB;

use OS_HTTP_REQUEST;

sub HTTP_REQUEST {

my $query = OS_HTTP_REQUEST::query;

my $pointer=index($query,"query_id");

if ($pointer==-1){

OS_SLB::forward(10);

}else{

  my $query_id=substr($query,$pointer+9,9);

  if ($query_id % 2 ==0) {

  OS_SLB::forward(1151);

  } else {

  OS_SLB::forward(1153);

  }

}

}