Forum Discussion
Moe_Jartin
Cirrus
Jan 05, 2009Context Root Masking/URL Rewrite and pool selection
I have an existing iRule that simply selects poolA based on a list of URIs, everything else goes to poolB.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
...
hoolio
Cirrostratus
Jan 06, 2009Once you add an HTTP profile to a VIP, a stream profile will only operate against the HTTP payload (not the HTTP headers). The response doesn't contain a URI exactly. A 30x redirect could contain a URL with the contextroot. You could use 'HTTP::header replace Location $new_value' to do this. Here is an example (Click here).
How many masked URI's are there? You could possibly read the masked URIs from the class and build a stream expression for each one, but I could see it being resource intensive if there are more than a few. Here is a quick example:
when RULE_INIT {
The prefix to remove
set ::uri_prefix "/contextroot"
A fake datagroup (actually a list) to test with
set ::masked_uris [list /uri1 /uri2 /uri3 /uri4]
Initialize a variable to test with.
This would be used to set the stream expression: STREAM::expression $stream_expression
set stream_expression ""
Loop through each element in the "datagroup"
foreach uri $::masked_uris {
Log the current element
log local0. "\$uri: $uri"
Append the current URI to the stream expression
set stream_expression "$stream_expression @$::uri_prefix$uri@$uri@"
Log the current stream expression
log local0. "\$stream_expression: $stream_expression"
}
Log the final result for the stream expression
log local0. "\$stream_expression: $stream_expression"
}
And the log output:
Rule : $uri: /uri1
Rule : $stream_expression: @/contextroot/uri1@/uri1@
Rule : $uri: /uri2
Rule : $stream_expression: @/contextroot/uri1@/uri1@ @/contextroot/uri2@/uri2@
Rule : $uri: /uri3
Rule : $stream_expression: @/contextroot/uri1@/uri1@ @/contextroot/uri2@/uri2@ @/contextroot/uri3@/uri3@
Rule : $uri: /uri4
Rule : $stream_expression: @/contextroot/uri1@/uri1@ @/contextroot/uri2@/uri2@ @/contextroot/uri3@/uri3@ @/contextroot/uri4@/uri4@
Rule : $stream_expression: @/contextroot/uri1@/uri1@ @/contextroot/uri2@/uri2@ @/contextroot/uri3@/uri3@ @/contextroot/uri4@/uri4@
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
