cancel
Showing results for 
Search instead for 
Did you mean: 

Request URL matching by Data Group

kmtmt_51646
Nimbostratus
Nimbostratus

Dear forum members,

 

 

It's my first time to play with Data Group. I created it from GUI like follows:

 

========

 

ltm data-group internal /Common/addresslist {

 

records {

 

address1 {

 

data www.abc.com

 

}

 

address2 {

 

data www.abcd.com

 

}

 

address3 {

 

data www.abcde.com

 

}

 

}

 

type string

 

}

 

========

 

 

and my iRule looks like this:

 

========

 

when HTTP_REQUEST {

 

if { [class match [HTTP::host] equals addresslist] }{

 

pool pool-1

 

return

 

}

 

}

 

========

 

 

I access to Virtual Server with hostname www.abc.com or www.abcd.com but it's not sent to the pool-1 at all.

 

pool-1 is accessble when I don't use this iRule, so the issue should be on the iRule or Data Group... Does anyone have a clue?

 

 

 

 

Thank you in advance,

 

 

4 REPLIES 4

What_Lies_Bene1
Cirrostratus
Cirrostratus
Try this instead. I think 'equals' won't work because of the string name and value pairing;

 

 

when HTTP_REQUEST { if { [class match [string tolower [HTTP::host] contains addresslist]] } { pool pool-1 return } }

nitass
F5 Employee
F5 Employee
e.g.

 

 

root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm virtual bar ltm virtual bar { destination 172.28.19.252:80 ip-protocol tcp mask 255.255.255.255 pool foo profiles { http { } tcp { } } rules { myrule } snat automap vlans-disabled } root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm data-group internal addresslist ltm data-group internal addresslist { records { www.abc.com { } www.abcd.com { } www.abcde.com { } } type string } root@(ve11a)(cfg-sync Changes Pending)(Active)(/Common)(tmos) list ltm rule myrule ltm rule myrule { when HTTP_REQUEST { set host [HTTP::host] if {[class match -- $host equals addresslist]} { pool pool-1 } } when SERVER_CONNECTED { log local0. "[IP::client_addr]:[TCP::client_port] | $host | [LB::server pool]" } } [root@ve11a:Active:Changes Pending] config tail -f /var/log/ltm Oct 4 21:58:35 tmm info tmm[9895]: Rule /Common/myrule : 172.28.19.251:36481 | www.abc.com | /Common/pool-1 Oct 4 21:58:52 tmm info tmm[9895]: Rule /Common/myrule : 172.28.19.251:36482 | www.other.com | /Common/foo Oct 4 21:58:57 tmm info tmm[9895]: Rule /Common/myrule : 172.28.19.251:36483 | www.abcd.com | /Common/pool-1 Oct 4 21:58:59 tmm info tmm[9895]: Rule /Common/myrule : 172.28.19.251:36484 | www.abcde.com | /Common/pool-1 Oct 4 21:59:03 tmm info tmm[9895]: Rule /Common/myrule : 172.28.19.251:36485 | www.xyz.com | /Common/foo

kmtmt_51646
Nimbostratus
Nimbostratus
Hi What Lies Beneath san

 

 

Thank you for your comment!

 

I tested to change "equals" to "contains" but didn't work, the cause was my data group itself.

 

 

But I really liked the idea of make strings lower case, so I figure the rule out shown below:

 

=====

 

if {[class match -- [string tolower $host] equals addresslist]} {

 

=====

 

 

kmtmt_51646
Nimbostratus
Nimbostratus
Hi nitass,

 

 

Thank you for your example!

 

Now I know I made a mistake on how to create data group, so I fixed it and set "--" option after class match then it started working.

 

 

I really appreciate it.

 

 

 

Sincerely,

 

 

kmtmt