Moe_Jartin
Feb 08, 2010Cirrus
Conditional 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* {
snatpool SNAT_DMZ
pool pool_www.mysite.org_URI1
}
/testlink* {
snatpool SNAT_APZ
STREAM::expression "@http://www.mysite.org@https://www.mysite.org@"
STREAM::enable
pool pool_www.mysite.org_TESTLINK
}
}
}
But then I realized that was only rewriting the request content and NOT the response content. So I need to catch/log the requested uri in a variable and only rewrite the content in the responses to the /testlink uri. Her is my attempt a pieceing together some examples I have found on the forum.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
/uri1* -
/uri2* {
snatpool SNAT_DMZ
pool pool_www.mysite.org_URI1
}
/testlink* {
snatpool SNAT_APZ
set requested-uri {[HTTP::uri]}
pool pool_www.mysite.org_TESTLINK
}
}
}
when HTTP_RESPONSE {
if {$requested-uri starts_with "/testlink"} {
STREAM::expression "@http://www.mysite.org@https://www.mysite.org@"
STREAM::enable
} else {
STREAM::disable
}
}
So my question is, Is a variable set during the HTTP_REQUEST event available under the HTTP_RESPONSE event? I have not been able to test this as this is a semi-production app.
Thanks,
Joe