Forum Discussion

iinoue_38219's avatar
iinoue_38219
Icon for Nimbostratus rankNimbostratus
Sep 07, 2011

Universal Persistence iRule

Hello, I'm a beginner of iRule.

I want to use Universal Persistence iRule across the two virtual-servers (whose pool-member's nodes are the same).

 

 

 

One virtual-server reply HTTP_RESPONSE whose Location contains the string (ticket=****).

 

A client sends to another virtual-server HTTP_REQUEST whose URI contains the string(ticket=***).

 

 

 

Those two connections must be used the same node.

 

 

 

I have made a iRule below, but it doesn't work well..

 

What is wrong with this?

 

 

 

 

 

when HTTP_RESPONSE {

 

set ticketid [findstr [HTTP::header Location] "ticket" 7]

 

if { $ticketid != "" } {

 

persist add uie [HTTP::header $ticketid]

 

}

 

}

 

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] contains $ticketid } {

 

persist uie [HTTP::header $ticketid]

 

}

 

else {

 

persist uie [HTTP::cookie ""]

 

}

 

}

 

 

 

 

 

 

Thanks.

 

 

 

1 Reply

  • not sure if i understand correctly. please feel free to revise.

     

     

    [root@iris1021:Active] config b virtual bar1 list

     

    virtual bar1 {

     

    snat automap

     

    pool foo

     

    destination 172.28.17.33:http

     

    ip protocol tcp

     

    persist mypersist

     

    profiles {

     

    http {}

     

    tcp {}

     

    }

     

    }

     

    [root@iris1021:Active] config b virtual bar2 list

     

    virtual bar2 {

     

    snat automap

     

    pool foo

     

    destination 172.28.17.44:http

     

    ip protocol tcp

     

    persist mypersist

     

    profiles {

     

    http {}

     

    tcp {}

     

    }

     

    }

     

    [root@iris1021:Active] config b profile mypersist list

     

    profile persist mypersist {

     

    defaults from universal

     

    mode universal

     

    across virtuals enable

     

    rule myrule

     

    }

     

    [root@iris1021:Active] config b rule myrule list

     

    rule myrule {

     

    when HTTP_RESPONSE {

     

    set ticketid [findstr [HTTP::header Location] "ticket" 7]

     

    if {$ticketid != ""} {

     

    persist add uie $ticketid

     

    }

     

    }

     

    when HTTP_REQUEST {

     

    set ticketid [URI::query [HTTP::uri] ticket]

     

    if {$ticketid != ""} {

     

    persist uie $ticketid

     

    }

     

    }

     

    }

     

     

    [root@iris1021:Active] config curl -I http://172.28.17.33/test

     

    HTTP/1.1 301 Moved Permanently

     

    Date: Wed, 07 Sep 2011 13:22:48 GMT

     

    Server: Apache/2.0.59 (rPath)

     

    Location: http://172.28.17.44/?ticket=3333

     

    Content-Type: text/html; charset=iso-8859-1

     

    [root@iris1021:Active] config curl -I http://172.28.17.44/?ticket=3333

     

    HTTP/1.1 200 OK

     

    Date: Wed, 07 Sep 2011 13:22:58 GMT

     

    Server: Apache/2.0.59 (rPath)

     

    X-Powered-By: PHP/4.3.11

     

    Set-Cookie: MyTestCookie=MyTestValue

     

    Content-Type: text/html; charset=UTF-8

     

    [root@iris1021:Active] config b persist show all

     

    PERSISTENT CONNECTIONS

     

    | Mode universal Value 3333

     

    | virtual 172.28.17.33:http node 10.10.70.130:http age 5sec