Forum Discussion

john_waterworth's avatar
john_waterworth
Icon for Nimbostratus rankNimbostratus
Oct 06, 2010

is it possible to consolidated multiple irules ito one irule

is it possible to consolidate the following irules into one irule

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] contains "/mtp/" } {

 

drop

 

}

 

}

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] contains "/console/" } {

 

drop

 

}

 

}

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] contains "/mtpadm/" } {

 

drop

 

}

 

}

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] contains "/remote-deploy/" } {

 

drop

 

}

 

}

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] contains "/juddi/" } {

 

drop

 

}

 

}

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] contains "/activeemg/" } {

 

drop

 

}

 

}

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] contains "/console-base/" } {

 

drop

 

}

 

}

 

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] contains "/debug-views/" } {

 

drop

 

}

 

}

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] contains "/plan-creator/" } {

 

drop

 

}

 

}

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] contains "/monitoring/" } {

 

drop

 

}

 

}

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] contains "/plugin/" } {

 

drop

 

}

 

}

 

 

when HTTP_REQUEST {

 

if { [string tolower [HTTP::uri]] contains "/system-database/" } {

 

drop

 

}

 

}

 

 

 

 

  • Hey John,

     

     

    This should definitely be possible. The switch operator ( http://devcentral.f5.com/wiki/default.aspx/iRules/switch.html ) is probably the best candidate for doing this. If these don't currently all apply to the same virtual server, there may be an argument for not gluing them all together for performance reasons. For example, if one of these URIs exists only on one virtual server, why make every virtual server parse the rule for it? If that isn't an issue, however, what you are probably looking for is something like this:

     

     

    when HTTP_REQUEST {

     

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

     

    "*/plan-creator/*" { drop }

     

    "*/mtp/*" { drop }

     

    et cetera

     

    et cetera

     

    }

     

    }

     

     

    Hope this helps!

     

     

    // Ben