Product Documentation

Configuring a Content Switching Action

Aug 31, 2016

You specify the target load balancing virtual server for a content switching policy when binding the policy to the content switching virtual server. Consequently, you have to configure one policy for each load balancing virtual server to which to direct traffic.

However, if your content switching policy uses a default syntax rule, you can configure an action for the policy. In the action, you can specify the name of the target load balancing virtual server, or you can configure a request-based expression that, at run time, computes the name of the load balancing virtual server to which to send the request. The action expression must be specified in the default syntax.

The expression option can drastically reduce the size of your content switching configuration, because you need only one policy per content switching virtual server. Content switching policies that use an action can also be bound to multiple content switching virtual servers, because the target load balancing virtual server is no longer specified in the content switching policy. The ability to bind a single policy to multiple content switching virtual servers helps to further reduce the size of your content switching configuration.

After you create an action, you create a content switching policy and specify the action in the policy, so that the action is performed when that policy matches a request.

Note: You can also, for a content switching policy that uses a default syntax rule, specify the target load balancing virtual server when binding the policy to a content switching virtual server, instead of using a separate action. For domain-based policies, URL-based policies, and rule based policies that use classic expressions, an action is not available. So, for these types of policies, you specify the name of the target load balancing virtual server when binding the policy to a content switching virtual server. For more information, see "Binding Policies to a Content Switching Virtual Server."

Configuring an Action that Specifies the Name of the Target Load Balancing Virtual Server

If you choose to specify the name of the target load balancing virtual server in a content switching action, you need as many content switching policies as you have target load balancing virtual servers. Content switching decisions, in this case, are based on the rule in the content switching policy, and the action merely specifies the target load balancing virtual server. When a request matches the policy, the request is forwarded to the specified load balancing virtual server.

To create and verify a content switching action that specifies the name of the target load balancing virtual server, by using the command line interface

At the command prompt, type:

  • add cs action <name> -targetLBVserver <string> [-comment <string>]
  • show cs action <name>

Example

> add cs action mycsaction -targetLBVserver mylbvserver -comment "Forwards requests to mylbvserver." 
 Done 
> show cs action mycsaction 
	Name: mycsaction 
	Target LB Vserver: mylbvserver 
	Hits: 0 
	Undef Hits: 0 
	Action Reference Count: 0 
	Comment: "Forwards requests to mylbvserver." 
 
 Done 
> 

To configure a content switching action that specifies the name of the target load balancing virtual server, by using the configuration utility

  1. Navigate to Traffic Management > Content Switching > Actions.
  2. Configure a content switching action, and specify the name of the target load balancing virtual server.

Configuring an Action that Specifies an Expression for Selecting the Target at Run Time

If you choose to configure a request-based expression that can dynamically compute the name of the target load balancing virtual server, you need to configure only one content switching policy to select the appropriate virtual server. The rule for the policy can be a simple TRUE (the policy matches all requests) because, in this case, content switching decisions are based on the expression in the action. By configuring an expression in an action, you can drastically reduce the size of your content switching configuration.

If you choose to configure a request-based expression for computing the name of the target load balancing virtual server at run time, you must carefully consider how to name the load balancing virtual servers in the configuration. You must be able to derive their names by using the request-based policy expression in the action.

For example, if you are switching requests on the basis of the URL suffix (file extension of the requested resource), when naming the load balancing virtual servers, you can follow the convention of appending the URL suffix to a predetermined string, such as mylb_. For example, load balancing virtual servers for HTML pages and PDF files could be named mylb_html and mylb_pdf, respectively. In that case, the rule that you can use in the content switching action, to select the appropriate load balancing virtual server, is "mylb_"+HTTP.REQ.URL.SUFFIX. If the content switching virtual server receives a request for an HTML page, the expression returns mylb_html, and the request is switched to virtual server mylb_html.

To create a content switching action that specifies an expression, by using the command line interface

At the command line, type the following commands to create a content switching action that specifies an expression and verify the configuration:

  • add cs action <name> -targetVserverExpr <expression>) [-comment <string>]
  • show cs action <name>

Example

> add cs action mycsaction1 -targetvserverExpr '"mylb_" + HTTP.REQ.URL.SUFFIX' 
 Done 
> show cs action mycsaction1 
	Name: mycsaction1 
	Target Vserver Expression: "mylb_" + HTTP.REQ.URL.SUFFIX 
	Target LB Vserver: No_Target 
               … 
 Done 
>

To configure a content switching action that specifies an expression by using the configuration utility

  1. Navigate to Traffic Management > Content Switching > Actions.
  2. Configure a content switching action, and specify an expression that will dynamically compute the name of the target load balancing virtual server.