gost2307_337235
Oct 24, 2017Nimbostratus
Replace string using stream profile from backend server to client
We have the problem to rewrite string in Stream Profile (iRule). The client is requesting the URL: "https://abc.com"; and the backend server responded with absolute URL Hostname "def.com". Because of this response we are getting failure message, so we want F5 to replace this string from "abc.com" to "def.com". We tried some different iRules but we couldn't achieve it. Please help us to find the solution. The following iRule we are using right now.
'' when HTTP_REQUEST {
Disable STREAM processing for request (ingress) traffic
STREAM::disable
Remove the Accept-Encoding header to disable server side compression
HTTP::header remove Accept-Encoding
Replace the incoming Host header to match what the server expects
HTTP::header replace Host "defp.com"
}
when HTTP_RESPONSE {
if { [HTTP::header exists Location] } {
If this is a redirect response, replace http://def.com with https://abc.com
HTTP::header replace Location [string map {"http://def.com" "https://abc.com"} [HTTP::header Location]
}
Use a STREAM expression to remap all object references in the payload (HTML body) with the external host name
STREAM::expression {@http://def.com@https://abc.com@ }
STREAM::enable
}