This article describes how to configure NetScaler for Content Switching based on User-Agent.
Currently the variety of devices accessing the content on the Internet have proliferated and the purposes of their access might also be very different. For instance, some clients are used only for Automation and requests are usually REST-API’s and other clients might come from mobile devices where the screen resolution is of smaller size and the bandwidth available is low.
Below is broad category of clients:In these scenarios it would be great if the requests land on the servers which will meet their unique needs. One of the ways to differentiate clients is based on the User-Agent and the following article explains the steps to configure the NetScaler to identify the behavior/capabilities of that particular client using the user-agent and to redirect the client to the server is tuned for meeting the needs of that particular client.
Overview diagram for configuring NetScaler for content switching based on user-agent
Complete the following steps to configure NetScaler for Content Switching based on User-Agent:
Step 1: For all the vserver and the device combinations identify the unique User-agent text. In all requests the User-Agent header will be there and from that the unique text can be derived.
Step 2: Configure the Content Switch policy.
GUI:
Traffic Management -> Content Switching > Policies -> Add.
In the below snapshot we see the Expression and in the expression the text within CONTAINS needs to be modified based on your requirement.
CLI:
add cs action useragentmozilla -targetLBVserver <vservername>
add cs policy useragent -rule "HTTP.REQ.HEADER(\"UserAgent\").CONTAINS(\"Mozilla\")\n"-action useragentmozilla
Step 3: Bind it to the Content Switch vserver and also select the appropriate the vserver which will handle the traffic.
GUI:
Traffic Management -> Content Switching -> Virtual Servers -> Edit ->Content Switch Policy Binding
CLI:
bind cs vserver vserveruser-agent -policyName useragent -priority 100
Step 4: Repeat steps 2 and 3 for all the vserver and user-agent combinations.