Forum Discussion
Moe_Jartin
Cirrus
Feb 08, 2010Conditional stream rewrite based on requested uri
I want to rewrite some content based on the uri that is requested. I started with:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
/uri1* -
/uri2* {
sna...
hoolio
Cirrostratus
Feb 08, 2010Hi Joe,
That looks like it would work. You could save a bit on the switch evaluation by setting the stream expression in a variable in HTTP_REQUEST for cases you want to use a stream profile for (and unsetting it by default on each request):
when HTTP_REQUEST {
Unset the stream_expr variable if it exists already
if {[info exists stream_expr]}{ unset stream_expr }
Check the requested URI
switch -glob [string tolower [HTTP::uri]] {
/uri1* -
/uri2* {
set stream_expr "@http://www.mysite.org@https://www.mysite.org@"
snatpool SNAT_DMZ
pool pool_www.mysite.org_URI1
}
/uri3* -
/uri4* {
set stream_expr "@http://www.mysite4.org@https://www.mysite4.org@"
snatpool SNAT_DMZ
pool pool_www.mysite.org_URI4
}
/uri5* -
/uri6* {
snatpool SNAT_DMZ
pool pool_www.mysite.org_URI4
}
/testlink* {
set stream_expr "@http://www.mysite.test.org@https://www.mysite.test.org@"
snatpool SNAT_APZ
pool pool_www.mysite.org_TESTLINK
}
}
}
when HTTP_RESPONSE {
if {[info exists stream_expr]} {
STREAM::expression $stream_expr
STREAM::enable
} else {
STREAM::disable
}
}
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
