Here is an idea on how to create a Content Switch, and hook up lots and lots (and lots) of VServers based on HTTP.REQ.HOSTNAME.
Step 1: Create the VServers, each with a unique prefix (i used LBAUTO_[fqdn]), but containing the fqdn…
-
1add lb vserver LBAUTO_www.mydomain.com
-
1add lb vserver LBAUTO_help.mydomain.com
- etc…
Step 2: Create a Contentswitch Action (Expression based), and a policy…
1 2 |
add cs action CSA_LBAUTO -targetVserverExpr "\"LBAUTO_\" + http.REQ.HOSTNAME add cs policy CSP_auto -rule true -action CSA_LBAUTO |
Bind it to the Content Switch.
If the HOSTNAME is not found as an LBAUTO_[fqdn] vserver, the contentswitch will proceed with the normal contentswitch policies…
As an alternative, you might want to consider using a Stringmap as a way to easily decide to which vserver a request should go to.
1 2 3 4 5 |
add policy stringmap SM_CS_FQDN_TO_LB bind policy stringmap SM_CS_FQDN_TO_LB www.mydomain.com LB_Server1 bind policy stringmap SM_CS_FQDN_TO_LB help.mydomain.com LB_Server2 add cs action CSA_LBAUTO2 -targetVserverExpr " HTTP.REQ.HOSTNAME.MAP_STRING(\"SM_CS_FQDN_TO_LB\")" |
Have fun!
Nice one, Roel! Very creative…
you’re missing a double-quote at the end of this line…
add cs action CSA_LBAUTO -targetVserverExpr “\”LBAUTO_\” + http.REQ.HOSTNAME”