Forum Discussion
PacketHead_4009
Dec 14, 2011Nimbostratus
Simple iRule with Sticky?
Hello, I'm trying to create what I think is a fairly simple iRule: when HTTP_REQUEST { if { [HTTP::uri] contains "/sites/tech*" } { pool Tech_Web_Pool_80 ...
hooleylist
Dec 14, 2011Cirrostratus
Browsers can set the Referer header to indicate which URI generated the current request:
http://tools.ietf.org/html/rfc2616section-14.36
The Referer[sic] request-header field allows the client to specify,
for the server's benefit, the address (URI) of the resource from
which the Request-URI was obtained (the "referrer", although the
header field is misspelled.) The Referer request-header allows a
server to generate lists of back-links to resources for interest,
logging, optimized caching, etc. It also allows obsolete or mistyped
links to be traced for maintenance. The Referer field MUST NOT be
sent if the Request-URI was obtained from a source that does not have
its own URI, such as input from the user keyboard.
http://tools.ietf.org/html/rfc2616section-15.1.3
Clients SHOULD NOT include a Referer header field in a (non-secure)
HTTP request if the referring page was transferred with a secure
protocol.
Here's an example which checks the URI and then the Referer header for multiple case insensitive patterns. Make sure to put the patterns in lower case as the URI and Referer header are set to lower case for the comparisons.
when HTTP_REQUEST {
Check the requested URI to see if it is a non-default pool request
switch -glob [string tolower [HTTP::uri]] {
"*/sites/tech*" -
"*/uri2/tech*" -
"*/uri3/tech*" {
pool Tech_Web_Pool_80
}
default {
No match on the URI, so check the Referer header
to see if it is a non-default pool request
switch -glob [string tolower [HTTP::header Referer]] {
"/sites/tech" -
"*/uri2/tech*" -
"*/uri3/tech*" {
pool Tech_Web_Pool_80
}
default {
No match on URI or Referer so use the main pool
pool Main_Web_Pool_80
}
}
}
}
}
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