For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

goldteet01_3332's avatar
goldteet01_3332
Icon for Nimbostratus rankNimbostratus
Apr 02, 2014

Can you nest IF into switch?

I would like to limit who can access the email part of website. Would this work?

 

when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/email" { if { [ class match [IP::remote_addr] equals $::white_list ] } { pool email } ** May have to do a redirect here *** } "/chat" { pool web-chat } default { pool web

 

} } }

 

1 Reply

  • John_Alam_45640's avatar
    John_Alam_45640
    Historic F5 Account

    You can use if inside switch. Your Irule should work except $::whitelist should be whitelist with the "class match" command.

     

    This is an important excerpt from the "class" command wiki page at: https://devcentral.f5.com/wiki/iRules.class.ashx

     

    Note that you should not use a $:: or :: prefix on the datagroup name when using the class command (or in any datagroup reference on 9.4.4 or later).

     

    In v9.4.4 - 10, using $::datagroup_name will work but demote the virtual server from running on all TMMs. For details, see the CMP compatibility page.

     

    In v11, using $::datagroup_name will result in a TCL runtime error and a reset being sent to the client!