Irule to match a URI and defined RH parameter has certain defined variable

Hello All, I’m trying to write an IRULE match an URI and a certain defined variable RH parameter value. If the condition met then it should forward the traffic to webserver else it should drop the traffic.

For example: if URI is X.com/obs.php?re* is in the URL, then the logic should validate the rh value from the list of defined values and only if the condition is met forward the traffic to webserver.

Here is the irule i tried.

Could you please help me to write the irule script for my request.

when HTTP_REQUEST { set variable XX

variables needs to be defined based on the value from IAM team)

if {[HTTP::URI] contains /obs.php?re*"} validate the rh value from a list of defined values if {[string tolower [URI::query [HTTP::uri] “RH”]] equals “xx”}{ pool POOLX } Redirect client else { HTTP::respond 403 } } else {pool POOLX } }

Regards, Thiyagu

here is the irule script: when HTTP_REQUEST { set variable XX if {[HTTP::URI] contains “/obs.php?re*”} if {[string tolower [URI::query [HTTP::uri] “RH”]] equals “xx”} { pool POOLX } else { HTTP::respond 403 } } else if {pool POOLX } }

Hi,

Does the uri really contains the * character?

Thanks Stanislas for your reply. I’m good with the script if I’m trying to match only a single variable.

Could you please help me to know how I can match multiple variables?

For example if I have to match 10 variables, Do I need use 10 “if else” to match one after the another parameter? Or is there a way to match multiple variable in single if statement like below?

likely the condition match xx or yy or zz then forward it to pool XX

if {[string tolower [URI::query [HTTP::uri] “RH”]] equals “xx” or equals YY or equlas ZZ} { pool POOLX } Does the above script syntax will work?

Thanks a lot in advance for your help.

Regards, Thiyagu

If you want to check multiple URLs, you can use switch command instead of if / elseif / elseif / else…

when HTTP_REQUEST {
    set variable XX
    switch -glob -- [HTTP::uri] {
        "/obs.php?abc*" - 
        "/obs.php?def*" - 
        "/obs.php?re*" {
            if {[string tolower [URI::query [HTTP::uri] "RH"]] equals "xx"} {
                pool POOLX
            }
            else {
                HTTP::respond 403
            }
        }
        default {pool POOLX }
    }
}

the dash character at the end of each value is like a or between values.