Forum Discussion
youssef1
May 01, 2019Cumulonimbus
Hi, I so firs of try this irule:
replace:
- poolmember_fqdn1 by real hostname (fqdn) of your pool member
- poolmember_fqdn2 by real hostname (fqdn) of your pool member
Irule:
when HTTP_REQUEST {
save hostname for use in response
set vip_fqdn [HTTP::host]
}
when HTTP_RESPONSE {
Rewrite the Location header for redirects
if { [HTTP::header exists Location] }{
HTTP::header replace Location [string map {"http://poolmember_fqdn1:8010" "http://$vip_fqdn" "http://poolmember_fqdn2:8010" "http://$vip_fqdn"} [HTTP::header Location]]
}
}
Then if you backend app is developped with absolute link without Relativ you can use this irule:
when HTTP_REQUEST {
Disable the stream filter for requests
STREAM::disable
Remove this header to prevent server from compression response
HTTP::header remove Accept-Encoding
save hostname for use in response
set vip_fqdn [HTTP::host]
}
when HTTP_RESPONSE {
Rewrite the Location header for redirects
if { [HTTP::header exists Location] }{
HTTP::header replace Location [string map {"http://poolmember_fqdn1:8010" "http://$vip_fqdn" "http://poolmember_fqdn2:8010" "http://$vip_fqdn"} [HTTP::header Location]]
}
Rewrite the response content using a stream profile if it is text
if { [HTTP::header Content-Type] contains "text" } {
Set the stream expression with the find/replace strings
STREAM::expression "@poolmember_fqdn:8010@vip_fqdn@"
Enable the stream filter
STREAM::enable
}
}