fir3net
PPS-Firenetbanner-780.5x190-30-03-17

Brocade ADX - Cookie Persistance based on URI

Introduction

Within this article we will show you the steps needed to configure cookie persistence (insert) based on URI. i.e cookie persistence is only performed for a single URI.

Cookie Insert

When cookie insert persistence is configured the loadbalancer selects a server to the send the traffic to. The server id of the server is then added to a cookie which is inserted into the HTTP response back to the client. The cookie is then sent with further HTTP requests from the client. The loadbalancer inspects the cookie, and uses the serverid value to persist (forward) traffic onto the same server.

Commands

There are 4 main components that the commands are based in order to configured cookie persistence based on URI. They are,

  • CSW-Rules - The CSW rules define the match criteria. i.e when x equals y. Here we define 2 rules. They are:
    • Cookie - When the HTTP header equals cookie and the name contains SERVERID=. 
    •  URI - When the URL prefix is /sales.
  • CSW-Policy - The policy defines the actions that are taken when the CSW rule is matched. The logic is as follows,
    • Take the server-id from the cookie and persist. Should the cookie exist.
    • If the uri is /sales then forward to group 2 and also insert a cookie containing the server id.
    • If none of the above is actioned then forward to group 1.
  • Real Servers - Each server has a server id configured. This is used to populate the ServerID cookie. Each server is also configured with a group id. This group is referenced within the csw-policy.
  • Virtual Server - Within the virtual server the csw-policy is assigned to a port.

Configuration

csw-rule "cookie_exist" header "cookie" pattern "SERVERID=" case-insensitive
csw-rule "uri_sales" url prefix "/sales" case-insensitive

csw-policy "cookie_persist" case-insensitive
  match "cookie_exist" persist offset 0 length 4 group-or-server-id
  match "uri_sales" forward 2
  match "uri_sales" rewrite insert-cookie "ServerID" "*" "/sales"
  default forward 1

server real RS1 10.1.100.1
  port http
  port http url "HEAD /"
  port http server-id 1211
  port http group-id 1 1

server real RS2 10.1.100.2
  port http
  port http url "HEAD /"
  port http server-id 1212
  port http group-id 1 1

server real RS3 10.1.200.3
  port http
  port http url "HEAD /"
  port http server-id 1213
  port http group-id 2 2

server real RS4 10.1.200.4
  port http
  port http url "HEAD /"
  port http server-id 1214
  port http group-id 2 2

server virtual VIP1 192.168.1.3
  port http
  port http csw-policy "cookie_persist"
  port http csw
  bind http RS1 http RS2 http RS3 http RS4 http

Tags: ADX, CSW, Persistence

About the Author

RDonato

R Donato

Rick Donato is the Founder and Chief Editor of Fir3net.com. He currently works as a Principal Network Security Engineer and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001