Forum Discussion
LoveNoodles
Altocumulus
Sep 01, 2009irule - persistance for url path
Hi There;
What would be the syntax to create an irule to apply source address persistance for a particular URL path, specifying a specific timeout setting in the process.
...
hoolio
Cirrostratus
Sep 01, 2009The iRule persist command would take precedence over the VIP's configuration. If you want to do exactly what you've described (persist requests for a specific URI longer than the default VIP profile), you can use an iRule like this:
when HTTP_REQUEST {
Check requested path
switch -glob [HTTP::path] {
"/apps/aml/*" {
Persist client for 10 hours
persist source_addr 36000
}
default {
Persist client for 1 hour
persist source_addr 3600
}
}
}
I think you'd need to specify the persistence timeout for both matching and non-matching requests as the persistence from the VIP may not be used for subsequent HTTP requests over the same TCP connection. You could test this by making requests over the same TCP connection (one which matches the URI check and one that doesn't) and checking the 'b persist all show all' output. You would want to comment out the second persist command (persist source_addr 3600) while testing this to see if the timeout on the VIP's persistence profile is used.
Also, if a client would typically make a request to /apps/aml and then a later request to a non-"/apps/aml" URI, you would probably still want to keep their persistence timeout set to 10 hours. Else, a client who first requested "/apps/aml" received a 36000 timeout record, requested a non-"/apps/aml" URI and received a 3600 timeout record and then waited more than 3600 seconds to make the next request would no longer get persisted to the same server as when they first requested "/apps/aml". I hope that's clear, but please reply if it's not.
To handle this, you might want to use uie persistence based on the client IP and some token which indicates they're getting a longer timeout:
when HTTP_REQUEST {
Check if there is an existing UIE persistence record
if {[persist lookup uie "[IP::client_addr]_apps"] ne ""}{
Use the existing UIE persistence record regardless of which URI was requested
persist uie "[IP::client_addr]_apps"] 36000
} else {
Check requested path
switch -glob [HTTP::path] {
"/apps/aml/*" {
Persist client for 10 hours using client IP _ apps
persist uie "[IP::client_addr]_apps" 36000
}
default {
Persist client for 1 hour
persist source_addr 3600
}
}
}
}
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects