Configure content switching in a Citrix ADC VPX Appliance
-
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.
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.
Before you begin
-
You have deployed a Citrix ADC VPX appliance and the appliance is UP and running in your setup. For more information, see Deploy a Citrix ADC VPX instance.
-
You have a basic understanding of the load balancing feature of a Citrix ADC appliance. For more information, see:
-
You have a basic understanding of the content switching feature of a Citrix ADC appliance. For more information, see:
-
You have a basic understading of the Citrix ADC NITRO REST APIs. For more information, see Citrix ADC NITRO API reference.
Configuration steps
-
Create a content switching virtual server
-
Create load balancing virtual servers
-
Create load balancing services
-
Bind the services to the load balancing servers
-
Create content switching policies
-
Bind content switching policies and load balancing virtual servers to the content switching virtual server
Create a content switching virtual server
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>}}'
Create load balancing virtual servers
lbvserver NITRO API object.
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>}'
Create load balancing services
service NITRO API object. You must create a service for each server to be load balanced.
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>" } }'
Bind the services to the load balancing servers
lbvserver_service_binding NITRO API object.
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>" } }'
Create content switching policies
cspolicy NITRO API object.
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>" }' }'
Bind content switching policies and load balancing virtual servers to the content switching virtual server
csvserver_cspolicy_binding NITRO API object.
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>" } }'
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" } }' |