Forum Discussion

Tom_Lauwereins_'s avatar
Tom_Lauwereins_
Icon for Nimbostratus rankNimbostratus
Feb 10, 2012

peristence based on HTTP header field

Hi,

 

 

I'm looking for a way to persist http requests based on the http header field.

 

How to do this via an iRule or is there a more easy way to handle the traffic always to the same pool memeber?

 

 

Kind Regards,

 

 

Tom

 

5 Replies

  • I have a few iRules that are setup which will parse the incoming URL, figure out which pool it should go to based off the URI and then puts a cookie into the header for persistence. Is that what you have in mind?
  • in case http header value is coming from client side and always shown in all request.

    e.g.

    [root@ve1023:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.19.79:80
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve1023:Active] config  b pool foo list
    pool foo {
       members {
          200.200.200.101:80 {}
          200.200.200.102:80 {}
       }
    }
    [root@ve1023:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
       if {[HTTP::header exists "Look-at-Me"]} {
          persist uie [HTTP::header "Look-at-Me"]
       }
    }
    }
    
    [root@ve1023:Active] config  b persist show all
    No Persistence Table Entries were found.
    
    [root@ve1023:Active] config  curl -I http://172.28.19.79 -H "Look-at-Me: helloworld"
    HTTP/1.1 200 OK
    Date: Sat, 11 Feb 2012 00:19:14 GMT
    Server: Apache/2.2.3 (CentOS)
    Last-Modified: Fri, 11 Nov 2011 14:48:14 GMT
    ETag: "4183e4-3e-9c564780"
    Accept-Ranges: bytes
    Content-Length: 62
    Content-Type: text/html; charset=UTF-8
    
    [root@ve1023:Active] config  b persist show all
    PERSISTENT CONNECTIONS
    |     Mode universal   Value helloworld
    |        virtual 172.28.19.79:80   node 200.200.200.101:80   age 2sec
    
    [root@ve1023:Active] config  curl -I http://172.28.19.79 -H "Look-at-Me: 12345"
    HTTP/1.1 200 OK
    Date: Sat, 11 Feb 2012 00:15:00 GMT
    Server: Apache/2.2.3 (CentOS)
    Last-Modified: Tue, 08 Nov 2011 12:26:29 GMT
    ETag: "4183f1-30-47e02740"
    Accept-Ranges: bytes
    Content-Length: 48
    Content-Type: text/html; charset=UTF-8
    
    [root@ve1023:Active] config  b persist show all
    PERSISTENT CONNECTIONS
    |     Mode universal   Value helloworld
    |        virtual 172.28.19.79:80   node 200.200.200.101:80   age 23sec
    |     Mode universal   Value 12345
    |        virtual 172.28.19.79:80   node 200.200.200.102:80   age 3sec