Configure content switching in a Citrix ADC VPX Appliance

In today’s complex Web sites, you may want to present different content to different users. For example:

  • you may want to allow users from the IP range of a customer or partner to have access to a special Web portal.
  • You may want to present content relevant to a specific geographical area to users from that area.
  • You may want to present content in different languages to the speakers of those languages.
  • You may want to present content tailored to specific devices, such as smartphones, to those who use the devices.

The Citrix ADC content switching feature enables the appliance to distribute client requests across multiple servers on the basis of specific content that you wish to present to those users.

A content switching configuration consists of a content switching virtual server, a load balancing setup consisting of load balancing virtual servers and services, and content switching policies. When a request reaches the content switching virtual server, the virtual server applies the associated content switching policies to that request. After it evaluates the policies, the content switching virtual server routes the request to the appropriate load balancing virtual server, which sends it to the appropriate service.

Consider an example in which Example Corp hosts a site at www.example.com. The site is hosted in two languages: English and French. The site in English content is hosted on two servers SVC-EN-1 and SVC-EN-2,and a load balancing virtual server, LBVS-EN, load balances these two servers. Similarly, the site in French content is hosted on two servers SVC-FR-1 and SVC-FR-2, and a load balancing virtual server, LBVS-FR, load balances these two servers. Both the load balancing servers LBVS-EN and LBVS-FR are associated with a content switching virtual server CSVS-1. Two content switching policies CSPOL-EN and CSPOL-FR are also associated with CSVS-1.

When an HTTP request reaches the CSVS-1, CSVS-1 uses the associated policies CSPOL-EN and CSPOL-FR to determine the language used in the request header. Based on the language determined, CSVS-1 routes the request to either LBVS-EN or LBVS-FR, which sends the request to one of its bound load balanced servers.

Before you begin

Before configuring content switching in a Citrix ADC VPX Appliance, make sure that:

Configuration steps

Configuring content switching in a Citrix ADC appliance consists of the following steps:

  1. Create a content switching virtual server
  2. Create load balancing virtual servers
  3. Create load balancing services
  4. Bind the services to the load balancing servers
  5. Create content switching policies
  6. Bind content switching policies and load balancing virtual servers to the content switching virtual server

Create a content switching virtual server

To create a content switching virtual server, you use the csvserver NITRO API object. For more information about the csvserver object and its properties, see Citrix NITRO API reference for csvserver.

Curl request

curl -X POST -H "Content-Type: application/json" -u <username>:<password>  http://<Citrix-ADC-IP-address(NSIP)>/nitro/v1/config/csvserver
-d '{"csvserver": { "name":"<value>", "servicetype":"<value>", "ipv46":"<value>", "port":<value>}}'
<!--NeedCopy-->

Create load balancing virtual servers

To create a load balancing virtual server, you use the lbvserver NITRO API object.

For more information about the lbvserver object and its properties, see Citrix NITRO API reference for lbvserver.

Curl request

curl -v -X POST  -H "Content-Type: application/json" -u <username>:<password> http://<Citrix-ADC-IP-address(NSIP)>/nitro/v1/config/lbvserver -d '{ "lbvserver": { "name":"<value>",  "servicetype":"<value>", "ipv46": "<value>", "port":<value>}'
<!--NeedCopy-->

Create load balancing services

To create a load balancing service, you use the service NITRO API object. You must create a service for each server to be load balanced.

For more information about the service object and its properties, see Citrix NITRO API reference for service.

Curl request

curl -v -X POST -H "Content-Type:application/json" -u <username>:<password> http://<Citrix-ADC-IP-address(NSIP)>/nitro/v1/config/service -d '{"service": { "name":"<value>", "ip":"<value>", "servicetype":"<value>", "port":"<value>" } }'
<!--NeedCopy-->

Bind the services to the load balancing servers

To bind the created services to the load balancing servers, you use the lbvserver_service_binding NITRO API object.

For more information about the lbvserver_service_binding object and its properties, see Citrix NITRO API reference for lbvserver_service_binding.

Curl request

curl -v -X PUT -H "Content-Type:application/json" -u <username>:<password> http://<Citrix-ADC-IP-address(NSIP)>/nitro/v1/config/lbvserver_service_binding -d '{"lbvserver_service_binding": { "name":"<value>", "servicename":"<value>", "weight":"<value>" } }'
<!--NeedCopy-->

Create content switching policies

To create a content switching policy, you use the cspolicy NITRO API object.

For more information about the cspolicy object and its properties, see Citrix NITRO API reference for cspolicy.

Curl request

curl -v -X POST -H "Content-Type:application/json" -u <username>:<password> http://<Citrix-ADC-IP-address(NSIP)>/nitro/v1/config/cspolicy -d '{"cspolicy": { "policyname":"<value>", "rule":"<value>" }' }'
<!--NeedCopy-->

Bind content switching policies and load balancing virtual servers to the content switching virtual server

To bind content switching policies and load balancing virtual servers to the content switching virtual server, you use the csvserver_cspolicy_binding NITRO API object.

For more information about the csvserver_cspolicy_binding object and its properties, see Citrix NITRO API reference for csvserver_cspolicy_binding.

Curl request

curl -v -X PUT -H "Content-Type:application/json" -u <username>:<password> http://<Citrix-ADC-IP-address(NSIP)>/nitro/v1/config/csvserver_cspolicy_binding -d '{"csvserver_cspolicy_binding": { "name": "<value>", "policyname": "<value>", "targetlbvserver": "<value>", "priority": "<value>" } }'
<!--NeedCopy-->

Sample configuration

Steps Curl requests
Create a content switching virtual server curl -X POST -H "Content-Type: application/json" -u nsroot:examplepassword http://192.0.0.33/nitro/v1/config/csvserver-d '{"csvserver": { "name": "CSVS-1", "servicetype": "HTTP", "ipv46": "203.0.113.5", "port": 80}}'
Create load balancing virtual servers curl -v -X POST -H "Content-Type: application/json" -u nsroot:examplepassword http://192.0.0.33//nitro/v1/config/lbvserver -d '{ "lbvserver": { "name":"LBVS-EN", "servicetype":"HTTP", "ipv46": "203.0.113.10", "port": 80}'

curl -v -X POST -H "Content-Type: application/json" -u nsroot:examplepassword http://192.0.0.33//nitro/v1/config/lbvserver -d '{ "lbvserver": { "name":"LBVS-FR", "servicetype":"HTTP", "ipv46": "203.0.113.20", "port": 80}'
Create load balancing services curl -v -X POST -H "Content-Type:application/json" -u nsroot:examplepassword http:// 192.0.0.33/nitro/v1/config/service -d '{"service": { "name": "SVC-EN-1", "ip": "192.0.2.10", "servicetype": "HTTP", "port": 80 } }'

curl -v -X POST -H "Content-Type:application/json" -u nsroot:examplepassword http:// 192.0.0.33/nitro/v1/config/service -d '{"service": { "name": "SVC-EN-2", "ip": "192.0.2.20", "servicetype": "HTTP", "port": 80 } }

curl -v -X POST -H "Content-Type:application/json" -u nsroot:examplepassword http:// 192.0.0.33/nitro/v1/config/service -d '{"service": { "name": "SVC-FR-1", "ip": "192.0.2.30", "servicetype": "HTTP", "port": 80 } }' 

curl -v -X POST -H "Content-Type:application/json" -u nsroot:examplepassword http:// 192.0.0.33/nitro/v1/config/service -d '{"service": { "name": "SVC-FR-2", "ip": "192.0.2.40", "servicetype": "HTTP", "port": 80 } }
Bind the services to the load balancing servers curl -v -X PUT -H "Content-Type:application/json" -u nsroot:examplepassword http://192.0.0.33/nitro/v1/config/lbvserver_service_binding -d '{"lbvserver_service_binding": { "name": "LBVS-EN", "servicename": "SVC-EN-1", "weight": "1" } }'

curl -v -X PUT -H "Content-Type:application/json" -u nsroot:examplepassword http://192.0.0.33/nitro/v1/config/lbvserver_service_binding -d '{"lbvserver_service_binding": { "name": "LBVS-EN", "servicename": "SVC-EN-2", "weight": "1" } }'

curl -v -X PUT -H "Content-Type:application/json" -u nsroot:examplepassword http://192.0.0.33/nitro/v1/config/lbvserver_service_binding -d '{"lbvserver_service_binding": { "name": "LBVS-FR", "servicename": "SVC-FR-1", "weight": "1" } }'

curl -v -X PUT -H "Content-Type:application/json" -u nsroot:examplepassword http://192.0.0.33/nitro/v1/config/lbvserver_service_binding -d '{"lbvserver_service_binding": { "name": "LBVS-FR", "servicename": "SVC-FR-2", "weight": "1" } }'
Create content switching policies curl -v -X POST -H "Content-Type:application/json" -u nsroot:examplepassword http:// 192.0.0.33/nitro/v1/config/cspolicy -d '{"cspolicy": { "policyname": "CSPOL-EN", "rule": "HTTP.REQ.URL.PATH_AND_QUERY.CONTAINS(\"en-us\")" } }'

curl -v -X POST -H "Content-Type:application/json" -u nsroot:examplepassword http:// 192.0.0.33/nitro/v1/config/cspolicy -d '{"cspolicy": { "policyname": "CSPOL-FR", "rule": "HTTP.REQ.URL.PATH_AND_QUERY.CONTAINS(\"fr\")" } }'
Bind content switching policies and load balancing virtual servers to the content switching virtual server curl -v -X PUT -H "Content-Type:application/json" -u nsroot:examplepassword http:// 192.0.0.33/nitro/v1/config/csvserver_cspolicy_binding -d '{"csvserver_cspolicy_binding": { "name": "CSVS-1", "policyname": "CSPOL-EN", "targetlbvserver": "LBVS-EN", "priority": "10" } }'

curl -v -X PUT -H "Content-Type:application/json" -u nsroot:examplepassword http:// 192.0.0.33/nitro/v1/config/csvserver_cspolicy_binding -d '{"csvserver_cspolicy_binding": { "name": "CSVS-1", "policyname": "CSPOL-FR", "targetlbvserver": "LBVS-FR", "priority": "20" } }'