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

} } }

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!