Forum Discussion

xett_113697's avatar
xett_113697
Icon for Nimbostratus rankNimbostratus
Nov 26, 2007

Updating Persistence from an iRule

I'm trying to find a way to update my persistence from a URL parameter. Here is my problem:

 

 

Lets say I have a pool called test-pool. In that pool I have server1, server2, server3. I need to be able to test that an application is functioning properly on each of the server, but I cannot access the server directly. I have to go through the F5 BigIP. What I would like to be able to do is add a parameter like query string like f5persistence=server1 which then would tell the iRule to change the persistence to server1. Now, I have been able to use the 'node' command to forward requests to the correct server, but on the next click in the application the f5persistence parameter goes away and I get pushed back to the original server.

 

 

Any help would be greatly appreciated.

10 Replies

  • Hello,

     

     

    What kind of persistence are you using now? If you specify a persistence profile on the virtual server and then make a request with the f5persistence parameter in the URI before any other type of persistence record exists, you should get persisted to the node specified in the rule. Else, if you want to explicitly add a persistence record after selecting the node the first time, you can use the persist command (Click here). Here is a post that looks like it fits the bill:

     

     

    Click here)

     

     

    Aaron
  • Thanks for your response Aaron.

     

     

    We have the Default Persistence Profile set to custom_source_addr with Mirror Persistence checked, Match Across Services checked, Match Across Virtual Servers checked, Match Across Pools unchecked, Timeout 10800, Mask: None, and Map Proxies checked.

     

     

    I set the virtual server's OneConnect profile to oneconnect with the following iRule, but it does not update the persistence record. If I remove the URI parameter I will be returned to the previous server.

     

     

     

    when HTTP_REQUEST {

     

     

    set requested_host ""

     

     

    ... logic for selecting the server from the URI because ...

     

    ... URI::query complains about wrong of args when retrieving a param ...

     

     

    switch $requested_host {

     

    "" {

     

    pool my-pool

     

    }

     

    "long" {

     

    node 10.0.0.10

     

    }

     

    "orbw" {

     

    node 10.0.0.11

     

    }

     

    default {

     

    pool my-pool

     

    }

     

    }

     

    }

     

     

     

     

    Thanks for your help.
  • Hi,

     

     

    What is the exact error you get when parsing the URI for the parameter? Can you add some logging to the beginning of the HTTP_REQUEST event before anything else is done?

     

     

    log local0. "URI: [HTTP::uri]"

     

    log local0. "Parsed value: [URI::query [HTTP::uri] your_parameter_name]"

     

     

    Can you also post the rule you're testing?

     

     

    Aaron
  • This is the error I get when I try to update the iRule:

     

     

    01070151:3: Rule [persist_to_server] error:

     

    line 5: [wrong args] [URI::query [HTTP::uri] f5host]

     

     

     

     

    Here is the iRule:

     

     

    when HTTP_REQUEST {

     

    set requested_host ""

     

     

    log local0. "URI: [HTTP::uri]"

     

    log local0. "Parsed value: [URI::query [HTTP::uri] f5host]"

     

     

    switch $requested_host {

     

    "" {

     

    pool my-pool

     

    }

     

    "long" {

     

    node 10.0.0.10

     

    }

     

    "orbw" {

     

    node 10.0.0.11

     

    }

     

    default {

     

    pool my-pool

     

    }

     

    }

     

    }

     

     

  • Try this:

     

     

    log local0. "Parsed value: [URI::query [HTTP::uri] "f5host"]"
  • I don't have any problem saving either format in 9.4.3. maybe it's an issue with your version?
  • You're probably right. We are running BIG-IP 9.1.2 Build 69.0.

     

     

    In any case, I have put together some code to parse the query string so that isn't really a problem. Do you know why my requests get sent back to the original server when I don't specify the f5host?

     

     

    Thanks,

     

    Jon
  • What do you see in the persistence table for the client IP? You can run 'b persist all show all' to see the records.

     

     

    Can you try adding the persistence record when a client uses a string in the URI to specify a node? You can add the following entry under each node statement:

     

     

    node 1.1.1.1

     

    persist source_addr custom_source_addr

     

     

    Also, is the client accessing the same app over two different protocols? If not, you don't need match across VIPs/pools enabled. And because HTTP connections are typically short-lived, it generally doesn't make sense to mirror the connection info.

     

     

    Aaron
  • One other thing... you might want to specify a port with the node command--particularly if you're vip is on a different port than the nodes:

     

     

    node 1.1.1.1 80

     

     

    Aaron