How do I Configure NetScaler for Content Switching Based on User-Agent?

How do I Configure NetScaler for Content Switching Based on User-Agent?

book

Article ID: CTX218014

calendar_today

Updated On:

Description

This article describes how to configure NetScaler for Content Switching based on User-Agent.

Use Case

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:
  1. Automation REST API Clients – No need for image related content
  2. Clients from Mobile devices – Smaller screen size and need for lesser bandwidth usage
  3. iPhone/iPad – Content might be delivered using Apple specific features
  4. Bot – Automated agents – crawler – For example will have “Googlebot” in their useragent
User-added image

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.


Instructions

Overview diagram for configuring NetScaler for content switching based on user-agent

User-added image



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.

User-added image

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

User-added image

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.

User-added image

Issue/Introduction

This article describes how to configure NetScaler for Content Switching based on User-Agent.