Basically I am trying to combine the two iRules below and only running the second iRule if the uri matches /vra.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::path] ] {
"/vra*" { pool VRA
log local0. "User directed to VRA" }
"/vdi*" { pool VDI
log local0. "User directed to EXT" }
default { pool somefallbackpool
log local0. "User directed to Fallback pool" }
}
}
when RULE_INIT {
Log debug messages to /var/log/ltm? 1=yes, 0=no
set static::rewrite_debug 1
External hostname for the web application
set static::external "externalwebpage.com"
Internal hostname for the web application
set static::internal "internalwebpage.com"
}
when HTTP_REQUEST {
if {$static::rewrite_debug}{log local0. "[IP::client_addr]:[TCP::client_port]: New HTTP request to [HTTP::host][HTTP::uri]"}
Prevent the server from sending compressed responses as LTM does not decompress them
HTTP::header remove "Accept-Encoding"
if {$static::rewrite_debug}{log local0. "[IP::client_addr]:[TCP::client_port]: Removing Accept-Encoding request header"}
Replace host header with the internal name
HTTP::header replace Host $static::internal
Disable the stream filter for non-text responses
STREAM::disable
}
when HTTP_RESPONSE {
Rewrite Location header value in HTTP redirects if it contains the $static::internal string
if {[HTTP::is_redirect] && [string tolower [HTTP::header "Location"]] contains $static::internal}{
Replace $static::internal with $static::external in Location header value
HTTP::header replace Location [string map "$static::internal $static::external" [HTTP::header Location]]
if {$static::rewrite_debug}{log local0. "[IP::client_addr]:[TCP::client_port]: Updated location from [HTTP::header Location]\
to [string map "$static::internal $static::external" [HTTP::header Location]]"}
}
Rewrite the response body if the response type is text
if { [HTTP::header "Content-Type"] starts_with "text/" } {
Configure the find/replace strings
STREAM::expression "@$static::internal@$static::external@"
Enable the stream filter
STREAM::enable
if {$static::rewrite_debug}{log local0. "[IP::client_addr]:[TCP::client_port]: Enabled stream filter for $static::internal -> $static::external"}
}
}