Need help with URL re-write without a redirect
I have virtual server on F5 with an iRule and want to add a condition for a new re-write. I have to re-write complete URL without redirecting or changing the URL in client's browser. Tested the below but client browsers keeps getting a reset. Below is my existing iRule and the syntax i have tried for re-write. Also attached few logs which show that traffic is matching the condition and re-writing the URL but fails.
Browser URL: "abc.domain.com/uri/path"
Backend URL: "abc4.domain4.com/file.html"
when HTTP_REQUEST {
set doStream 0
switch [HTTP::host] {
"abc.domain.com" {
if {[HTTP::path] contains "/abc/abc" && [HTTP::query] contains "location="} {
HTTP::respond 301 "Location" "https://[HTTP::host]/abc/[string tolower [findstr [HTTP::query] "location=" 9]]"
pool xyz_pool
} elseif {[string tolower [HTTP::host]] starts_with "abc.domain.com" && [HTTP::path] eq "/uri/path"}
{ HTTP::header replace Host "abc4.domain4.com"
HTTP::uri "/file.html"
set doStream 4
log local0. "[HTTP::host][HTTP::uri] Changed rewrite"
pool test-pool
} elseif {[class match [HTTP::path] equals "url_redirect_list"]} {
set newURL [class match -value -- [HTTP::uri] equals "url_redirect_list"]
log local0. "NEW Redirect URI is [HTTP::uri]"
HTTP::respond 301 "Location" $newURL
} elseif {[class match [HTTP::path] equals "url_explicit_list"]} {
log local0. "[HTTP::path]: Explicit URL path goes to [LB::server] with cookie value [HTTP::cookie value "cookie"]"
HTTP::header replace Host "abc1.domain.com"
set doStream 1
log local0. "[IP::client_addr]:[TCP::client_port]: [LB::server] Request with persistence cookie [HTTP::cookie value "cookie"] to [HTTP::uri]"
pool explicit_pool
} elseif {[class match [HTTP::path] starts_with "url_wildcard_list"]} {
log local0. "[HTTP::path]: Wildcard URL path goes to [LB::server]"
HTTP::header replace Host "abc1.domain.com"
set doStream 1
#log local0. "[HTTP::path]: Wildcard URL path goes to [LB::server]"
}
elseif { [string tolower [HTTP::uri]] ne "/autodiscover" } {
log local0. "[IP::client_addr]:[TCP::client_port]: [LB::server] Request with persistence cookie [HTTP::cookie value "cookie"] to [HTTP::uri]"
pool backend_pool
persist cookie insert "cookie"
} else {
drop
}
}
}
}
when HTTP_RESPONSE {
switch $doStream {
0 {
return
}
1 {
STREAM::expression {@http://abc1.domain.com@https://abc.domain.com@}
STREAM::enable
}
4 {
STREAM::expression {@https://abc4.domain4.com/file.html@https://abc.domain.com/uri/path@}
STREAM::enable
}
}
}
/var/log/ltm.1:Apr 14 13:44:55 info tmm1[17567]: Rule /Common/POOL_SELECTION_IRULE <HTTP_REQUEST>: abc4.domain4.com/file.html Changed rewrite
/var/log/ltm.1:Apr 14 13:44:55 info tmm[17567]: Rule /Common/POOL_SELECTION_IRULE <HTTP_REQUEST>: abc4.domain4.com/file.html Changed rewrite
/var/log/ltm.1:Apr 14 13:45:04 info tmm[17567]: Rule /Common/POOL_SELECTION_IRULE <HTTP_REQUEST>: abc4.domain4.com/file.html Changed rewrite
/var/log/ltm.1:Apr 14 13:45:05 info tmm1[17567]: Rule /Common/POOL_SELECTION_IRULE <HTTP_REQUEST>: abc4.domain4.com/file.html Changed rewrite
/var/log/ltm.1:Apr 14 13:45:05 info tmm[17567]: Rule /Common/POOL_SELECTION_IRULE <HTTP_REQUEST>: abc4.domain4.com/file.html Changed rewrite
/var/log/ltm.1:Apr 14 13:50:05 info tmm[17567]: Rule /Common/POOL_SELECTION_IRULE <HTTP_REQUEST>: abc4.domain4.com/file.html Changed rewrite
/var/log/ltm.1:Apr 14 14:00:06 info tmm[17567]: Rule /Common/POOL_SELECTION_IRULE <HTTP_REQUEST>: abc4.domain4.com/file.html Changed rewrite
/var/log/ltm.1:Apr 14 15:42:37 info tmm1[17567]: Rule /Common/POOL_SELECTION_IRULE <HTTP_REQUEST>: abc4.domain4.com/file.html Changed rewrite
Any help is appreciated.
Thanks
you would need to work with the application team to find out which URL's are returning 404 and reason for it. Modify your iRule accordingly to resolve it