Forum Discussion
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_45640Historic 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!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com