Replace http:// to https:// with i-rule

Dear all, I have a problem about it My Topology as under

client<-http-> F5-LTM <-http->Server

Here application working fine but problem is it give server ip address in http hesder

to resolve this we use followin i-rule

when HTTP_RESPONSE {

if { [HTTP::header is_redirect]} {

HTTP::header replace Location [string map -nocase {172.31.112.40 blrorsapp} HTTP::header value Location]]

}

}

It’s working & provide host name insted of ip

Now User wants access application as https

client<-https-> F5-LTM<-http-> Server

if i make redirect rewrite set to all client get f5 virtual ip address in the browser insted of host name

so what changes i have to do in irule to resolve this issue

Note:- if i set redirect rewrite set to none we get page cannot be display error

Try SOL6912: 404 Page not found | BIG-IP Documentation

If you want to rewrite the redirects from the virtual server IP to a hostname and from http:// to https://, you can modify the string map command:

when HTTP_RESPONSE {
    Check if response is a 30x redirect
   if { [HTTP::header is_redirect]} {
       Rewrite http:// to https:// and the IP to the hostname in the Location header value
      HTTP::header replace Location [string map -nocase "http:// https:// 172.31.112.40 blrorsapp" HTTP::header value Location]]
   }
}

Aaron

Dear Hoolio

I try the following 2 i-rule But the problem was not solved

when HTTP_RESPONSE {

if { [HTTP::header is_redirect]} {

Log original and updated values

log local0. "Original Location header value: [HTTP::header value Location],\

updated: [string map -nocase “http:// https:// :80/ /” [HTTP::header value Location]]" Do the update, replacing old.hostname.com with new.hostname.com and replacing http:// with https:// and :80/ with /

HTTP::header replace Location

[string map -nocase “http:// https:// :80 /” {old.hostname.com new.hostname.com} [HTTP::header value Location]]

}

}

Actually the application put node ip address in the header, so if i set the rewrite redirect set to all the application is working but it shows the f5 vip in the client browser

& client wants the host name in browser insted of the f5 vip

Hi Kris,

Can you try something like this then to replace the node IP with the hostname?

when HTTP_RESPONSE {
    Check if response is a 30x redirect
   if { [HTTP::header is_redirect]} {
       Rewrite http:// to https://, the IP to the hostname and remove the port reference in the Location header value
      HTTP::header replace Location [string map -nocase "http:// https:// [IP::server_addr] blrorsapp :80/ /" HTTP::header value Location]]
   }
}

Aaron