Product Documentation

Use Case: Dynamic Content Switching

May 21, 2015

This use case provides dynamic content switching by using an HTTP callout to get the name of the load balancing virtual server to which the request is forwarded.

  1. Add a content switching virtual server.
    > add cs vserver cs_vserver1 HTTP 10.102.29.196 80
  2. Create an HTTP callout.
    > add policy httpCallout http_callout1
  3. Configure the HTTP callout to respond with the name of the load balancing virtual server from a request that contains the client IP address in the HTTP header "X-CLIENT-IP".
    > set policy httpCallout http_callout1 -IPAddress 10.217.14.23 -port 80 -returnType TEXT -hostExpr "\"www.get-lbvip.com\"" -urlStemExpr "\"/index.html\"" -headers X-CLIENT-IP(CLIENT.IP.SRC) -resultExpr "HTTP.RES.BODY(1000).AFTER_STR(\"<lbvip>\").BEFORE_STR(\"</lbvip\")"
  4. Configure the content switching action to retrieve the callout response.
    > add cs action cs_action1 -targetVserverExpr 'SYS.HTTP_CALLOUT(http_callout1)'
    Note: You must bind a load balancing virtual server to the content switching virtual server to account for:
    • The non-availability of the load balancing virtual server that the callout resolves to.
    • A UNDEF condition that results from the execution of the callout.
    > bind cs vserver cs_vserver1 -lbvserver default_lbvip
  5. Configure the content switching policy.
    > add cs policy cs_policy1 -rule true -action cs_action1
  6. Binding the content switching policy to the content switching virtual server.
    > bind cs vserver cs_vserver1 -policyName cs_policy1 -priority 10