Jump to content
Welcome to our new Citrix community!

Content switching on two differnet url


Miroslav Dosic

Recommended Posts

Hi

 

I am quite new in Citrix.

How can i configure content switching for example if i have two servers 1.1.1.1 and 1.1.1.2.

And if i go to http://url1 it will go to 1.1.1.1 an if i go to http://url2 i will go to 1.1.1.2.

VIP address for both URLs is 2.2.2.2

 

Thank you

Best regards

Miroslav

Link to comment
Share on other sites

Hi

Check if the following article helps: https://docs.citrix.com/en-us/netscaler/12/content-switching/basic-configuration/configure-policies.html

Simple example:

add lb vserver lb_vs_XXX HTTP 0.0.0.0 0 
add cs action cs_act_XXX -targetLBVserver lb_vs_XXX
add cs policy cs_plc_XXX -rule "HTTP.REQ.URL.PATH.SET_TEXT_MODE(IGNORECASE).CONTAINS(\"/url1\")" -action cs_act_XXX
bind cs vserver csvip_xxx -policyName cs_plc_XXX -priority 240
 

 

Link to comment
Share on other sites

Diego is pointing you to some decent CS examples. Just adding some clarifying notes.

 

If 1.1.1.1 and 1.1.1.2 are your backend servers, then create an Lb vserver to get you to backend server1 (1.1.1.1) and and an lb vserver for backend server2 (1.1.1.2).  The lb tier can be non-addressable and act as an ns-only entity.  Which are what those 0.0.0.0 entity is in diego's example. 

Diego's example also sorts based on URL path and not based on host FQDN (based on your sample above), but other variations are possible depending on what exactly you want to sort on.

 

CS policies identify the traffic of interest and using a cs action direct traffic meeting the criteria to the destination specified.

Users aren't redirected; users hit CS VIP and CS directs internally to LB vserver, and then the LB vserver directs traffic to actual destination (service ip).  The LB vserver in the above example only directs traffic to a single destination.  But it could also be used for actual load balancing.

 

If you want the user to hit a cs vserver and get redirected to a new public VIP based on which path they hit, then a responder policy would be used instead.

Link to comment
Share on other sites

Diego gave you the outline for how it will work.  If you need a more detailed example, try this.

 

# LB/Service tier and initial CS vserver

# This is the backend part to the example Diego started you with:

add service svc1 1.1.1.1 http 80

add service svc2 11.1.12 http 80

add lb vserver lb_vsrv1 http 0.0.0.0 0

   bind lb vserver lb_vsrv1 svc1

add lb vserver lb_vsrv2 http 0.0.0.0 0

   bind lb vserver lb_vsrv2 svc2

add cs vserver cs_vsrv_demo http <VIP1> 80

# next cs policies

 

Now, the question is you say URL1 vs URL2 are they varying by FQDN or PATH?

We can use content switching to sort by either, but it helps to know which one.

 

Example 1: by complete url including FQDN

First this requires that your dns resolves both hostnames to the same VIP of the CS vserver

URL1:  http://app1.domain.com/<stuff>

URL2:  http://app2.domain.com/<stuff>

 

# Policies by FQDN/complete URL

add cs action cs_act_tosrv1 -targetlbvserver lb_vsrv1   #will send to svc1 (1.1.1.1)

add cs action cs_act_tosrv2 -targetlbvserver lb_vsrv2  # will send to svc2 (1.1.1.2)

 

add cs policy cs_pol_tosrv1 -rule 'http.req.header("host").set_text_mode(ignorecase).contains("appa.domain.com")' -action cs_act_tosrv1

add cs policy cs_pol_tosrv2 -rule 'http.req.header("host").set_text_mode(ignorecase).contains("appb.domain.com")' -action cs_act_tosrv1

bind cs policy cs_vsrv_demo -policyName cs_pol_tosrv1 -priority 100

bind cs policy cs_vsrv_demo -policyName cs_pol_tosrv2 -priority 200

 

Example 2:  sort by start of URL path

URL1:  http://demo.domain.com/appa/<stuff>

URL2:  http://demo.domain.com/appb/

 

# Policies based on Path:

#  Use same actions as above

add cs policy cs_pol_tosrv1 -rule 'http.req.url.path.set_text_mode(ignorecase).starts_with("appa")' -action cs_act_tosrv1

add cs policy cs_pol_tosrv2 -rule 'http.req.url.path.set_text_mode(ignorecase).contains("appb")' -action cs_act_tosrv1

bind cs policy cs_vsrv_demo -policyName cs_pol_tosrv1 -priority 100

bind cs policy cs_vsrv_demo -policyName cs_pol_tosrv2 -priority 200

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...