For more details, please see ourCookie Policy.

Application Delivery (ADX)

Using CSW to do load balancing based on the host header

by on ‎05-08-2009 06:23 AM (525 Views)


We want to load balance requests based on the hostname header inside the HTTP requests. In this example, there is a separate group of real servers for each hostname header and requests for unknown host headers should get a reset back from the ServerIron/ADX.

To achieve this we are going to parse the traffic using a csw policy – there  are two domains ( and and there is a dedicated web  server for each domain. Requests for any other domain will get a TCP RST packet  back.


We will use Layer-7 switching using csw to achieve this. Please remember the  following things:

  • Each request which does not match any of the configured rules is going to  hit the default rule - the default rule is configure to send a RESET to the  client.
  • The example is based on groups with a single server in each group – it is  possible to have multiple servers in each group. The ServerIron is going to load  balance in between the real servers in the selected group in case there are  multiple servers in the group.

The virtual server receiving the request is the one with IP address Requests with host header need to go to real  server rs101 (, requests with host header to real  server rs102 ( and all other request will get a RESET back.

Topology Diagram

not needed

Sample Code/Configuration

csw-rule "domA" header "host" equals "WWW.DOMAINA.DE" case-insensitive
csw-rule "domB" header "host" equals "WWW.DOMAINB.DE" case-insensitive
csw-policy "MP" case-insensitive
match "domA" forward 1
match "domB" forward 2
default reset-client
server real rs101
port http
port http url "HEAD /"
port http group-id  1 1
server real rs102
port http
port http url "HEAD /"
port http group-id  2 2
server virtual vs200
port http
port http csw-policy "MP"
port http csw
bind http rs101 http rs102 http

Verification Guideline

  • Use some clients to send requests with a known host header in – check the  statistics related to the defined csw rule. Each rule does have a counter to  show the amount of hits related to this rule.

ServerIron# show csw-policy MP

Policy Name           :MP

Policy Type            :Content Switching
Policy index           : 1
Reference Count     : 1
total received packe: 0
created session      : 0                 total scanned packet : 0
no session drop      : 0                 no session frag drop  : 0
send mirror ip packe: 0                send mirror packet     : 0
send redirect packet: 0                case-insensitive         : TRUE

Action code description:
fwd: forward    rst: reset-client       per: persist
rdr: redirect   err: reply-error        got: goto
rwt: rewrite    mir: mirror             log: log
con: count      drp: drop       rec: vir-reset
red: cont-red   mip: mirror-ip  unk: unknown

Flag description:
A: insert-cookie        B: delete-cookie        C: destroy-cookie
D: req-ins-hdr          E: req-ins-client-ip    F: resp-ins-hdr
G: delete-content       H: insert-content       I: modify-content
L: log

Rule Name   |Act|Data1     |Data2     |Data3     |Flags     |Hit Cnt
domA       |     |      |               |     |5          |
domA       |fwd|1         |          |N/A       |_________ |5
domB       |     |      |               |     |6          |
domB       |fwd|2         |          |N/A       |_________ |6
default     |     |      |               |     |2          |
default     |rst|N/A       |N/A       |N/A       |_________ |2

by bcsc
on ‎03-20-2010 09:02 AM

goog job