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.

  1. 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.

  1. Navigate to the Configuration tab on the top menu bar.
  2. Select LOCAL TRAFFIC > iRules

image24

  1. Click the Create button under iRules

image25

  1. 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 } }

image26

  1. Navigate to LOCAL TRAFFIC > Virtual Servers

image27

Type ITwiki in the filter box on the right hand side of the screen and press return.

image28

Click to select all the matching virtual servers

image29

Click the Attach iRules button at the top of the screen

image30

Fill out the Attach iRules section
iRules: Select the VS_maintenance_irule iRule

image31

Click Save & Close in the lower right.

Clear the filter from the Virtual Servers

image32