Loadbalancing based on header on Brocade ADX
Goal ------ We have three servers. For sake of simplicity let's name them lx11, lx12 and lx13. Our goal is to have standard loadbalancing VIP (round-robin), but we need ability to force the connection to go to a specific server by setting appropriate header value in a HTTP request. Assumptions ------------------ * Real servers are configured and alive. * All of them have their server-id assigned. In our example its 1218, 1211 and 1213. Solution ----------- * Verify if the servers have their IDs assigned
server real linux-117.11 192.168.117.11 port http port http keepalive port http url "HEAD /" port http server-id 1218 port http group-id 1 1 ! server real linux-117.12 192.168.117.12 port http port http keepalive port http url "HEAD /" port http server-id 1211 port http group-id 1 1 ! server real linux-117.13 192.168.117.13 port http port http keepalive port http url "HEAD /" port http server-id 1213 port http group-id 1 1 !
In order to extract the value from the headers, we need to use CSW policies. Technically, we could use CSW policy to configure the persistence but we have explicit requirement that it needs to be just for part of the servers. Also, this method does not disclose what our server-ids are. * Create CSW rules
csw-rule "j11" header "MyServerID" equals "Server117.11" csw-rule "j12" header "MyServerID" equals "Server117.12" csw-rule "j13" header "MyServerID" equals "Server117.13"
* Create CSW policy
csw-policy "hdr_balance" match "j11" forward 1218 match "j12" forward 1211 match "j13" forward 1213
* Apply CSW policy to the VIP
! server virtual VIP1 192.168.112.250 port http sticky port http csw-policy "hdr_balance" port http csw bind http linux-117.11 http linux-117.12 http linux-117.13 http !
* If you want to test if this works and you have ability to find out which server are you using based on the response, you can fire a HTTP request with specified header towards the server:
skrobul > curl http://192.168.80.250/jsessionid.php -H "MyServerID: Server117.13" -v * About to connect() to 192.168.80.250 port 80 (#0) * Trying 192.168.80.250... * connected * Connected to 192.168.80.250 (192.168.80.250) port 80 (#0) > GET /jsessionid.php HTTP/1.1 > User-Agent: curl/7.26.0 > Host: 192.168.80.250 > Accept: */* > MyServerID: Server117.13 > * HTTP 1.0, assume close after body < HTTP/1.0 200 OK < Date: Tue, 03 Jul 2012 18:35:48 GMT < Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.25 with Suhosin-Patch < X-Powered-By: PHP/5.2.4-2ubuntu5.25 < Set-Cookie: JSESSIONID=balblahlahla_SERVER117.13 < Content-Length: 24 < Connection: close < Content-Type: text/html <
Server 117.13
* Closing connection #0 skrobul >










