Newbie on iRules here seeking help from you gurus.
I want to move this apache functionality to the Big-IP using iRules but I don’t even know how to begin searching devcentral. I tried looking for it and the closest I think the equivalent is the STREAM profile. Tried it but of course it didn’t work. Maybe I just don’t understand STREAM profile.
This is the apache config:
RewriteEngine on
RewriteCond %{HTTP_HOST} test.domain.com$
RewriteRule ^/*(.+) /web/foo/$1 [PT]
tomcat backend
JkMount /* instance21
What this does:
1. My documentRoot is from the tomcat app servers serving /* - hence the jkmount /* function.
I think this should be equivalent to the Apache rewrite rule:
when HTTP_REQUEST {
Check if the host is test.domain.com and the path does not already start with /web/foo
if {[string tolower [HTTP::host]] eq "test.domain.com"}{
if { not ([HTTP::path] starts_with "/web/foo")}{
Prepend /web/foo to the path
HTTP::path "/web/foo[HTTP::path]"
}
}
}
And here’s a version which works with a stream profile to rewrite the response content and redirect Location header from /web/foo to nothing:
when HTTP_REQUEST {
Disable the stream filter by default
STREAM::disable
Check if the host is test.domain.com and the path does not already start with /web/foo
if {[string tolower [HTTP::host]] eq "test.domain.com"}{
if { not ([HTTP::path] starts_with "/web/foo")}{
Prepend /web/foo to the path
HTTP::path "/web/foo[HTTP::path]"
}
}
}
when HTTP_RESPONSE {
Rewrite redirects
if {[HTTP::is_redirect] && [URI::path [HTTP::header Location]] starts_with "/web/foo"}{
HTTP::header replace Location [string map {/web/foo ""} [HTTP::header Location]]
}
Set the stream expression for text responses
if {[HTTP::header Content-Length] contains "text"}{
STREAM::expression {@/web/foo@@}
STREAM::enable
}
}
1. on your first suggestion, it doesn’t seem to get the data from /web/foo on the tomcat server. All it get is the tomcat’s default page not the contents from /web/foo
2. on the stream suggestion, same results as above, my stream profile has this:
It shouldn’t be a problem rewriting chunked responses. If you had the server sending compressed responses you’d need to uncompressed them or reconfigure the server to not use compression. But that response isn’t compressed.
As far as the request URI rewriting, did that curl request return the content you were expecting? If so, can you compare the server logs for the request made via the VIP and iRule with the one direct to the server from the LTM command line?