F5 BIG-IQ Centralized Management Lab > BIG-IQ All Labs > Class 6: BIG-IQ LTM Configuration Management > Module 2: Local Traffic Management Virtual Servers from the Configuration Tab Source | Edit on
Lab 2.3: Create iRule and attach to multiple virtual servers¶
Note
Estimated time to complete: 10 minutes
Lab environment access¶
If you have not yet visited the page Getting Started, please do so.
Tasks¶
BIG-IQ allows users to create iRules and use them on the virtual servers that are managed by BIG-IQ. The iRules can be attached to individual virtual servers or iRules can be attached to multiple virtual servers in the same operation.
In this scenario, we will apply an iRule to a number of our virtual servers that presents a maintenance page if none of the pool members supporting the virtual are online and available.
You can create an iRule on the BIG-IQ directly.
To save time the VS_maintenance_irule has already been created on the BIG-IQ.
- Steps 1-5 show that you can create an iRule on the BIG-IQ directly.
To save time the VS_maintenance_irule has already been created on the BIG-IQ.
Note
Skip to step 6 to apply the already configured iRule, or you may create your own iRule for this lab.
- Navigate to the Configuration tab on the top menu bar.
- Select LOCAL TRAFFIC > iRules
- Click the Create button under iRules
- Fill out the iRule Properties page | Name: VS_maintenance_irule | Partition: Common | body: as below:
when RULE_INIT { # sets the timer to return client to host URL set static::stime 10 }
when CLIENT_ACCEPTED { set default_pool [LB::server pool] }
when HTTP_REQUEST { # Check if the URI is /maintenance switch [HTTP::uri] {
“/maintenance” {
# Send an HTTP 200 response with a Javascript meta-refresh pointing to the host using a refresh time HTTP::respond 200 content \ “<html><head><title>Maintenance page</title></head><body><metahttp-equiv=’REFRESH’ content=$static::stime;url=[HTTP::uri]></HEAD>\ <p><h2>Sorry! This site is down for maintenance.</h2></p></body></html>” “Content-Type” “text/html” return } }
# If the default pool is down, redirect to the maintenance page if { [active_members $default_pool] < 1 } { HTTP::redirect “/maintenance” return } }
- Navigate to LOCAL TRAFFIC > Virtual Servers
Type ITwiki in the filter box on the right hand side of the screen and press return.
Click the Attach iRules button at the top of the screen
- Fill out the Attach iRules section
- iRules: Select the VS_maintenance_irule iRule
Click Save & Close in the lower right.
Clear the filter from the Virtual Servers