Forum Discussion

Blue_whale's avatar
Blue_whale
Icon for Cirrocumulus rankCirrocumulus
Apr 11, 2022

Need help to understand the irule

Hi experts , 

I need help to understand the below irule , 

Why we have 2 condition for the same url , 1 to replace the host and then to redirect to the pool ?

VIP url ; https://csk-net-corp.aci.network/test/network/lb/corp/v1

 

when HTTP_REQUEST {

if { ([string tolower [HTTP::path]] starts_with "/X509/services" )} then

{

## rien

} else

{

if {([string tolower [HTTP::host]] equals "csk-net-corp.aci.network")}{

HTTP::header replace Host "csk-net-bw.aci.network"

if { [HTTP::path] starts_with "/test/network" } { pool P_CSK_NET_5001

}

}
}

  • To update the Host header value without redirecting the client to the new Host value, you can use HTTP::header replace Host “csk-net-bw.aci.network”. This update will only affect the request to the pool member. The client will not see the update unless the web application uses the requested host header value to generate response headers and/or content.

     

    if {([string tolower [HTTP::host]] equals "csk-net-corp.aci.network")}{
    HTTP::header replace Host "csk-net-bw.aci.network"
    }

     

     In 2nd request, traffic are served by different group of pool member if condition matches. URL will be remain same csk-net-corp.aci.network

     

    if { [HTTP::path] starts_with "/test/network" } { pool P_CSK_NET_5001
    }

     

     

    • Blue_whale's avatar
      Blue_whale
      Icon for Cirrocumulus rankCirrocumulus

      Hi Samir  , thanks for your reply .. 

      I have few doubts ,

      1) In my case both the condition or request are there in the same irule.So it will replace the host header and also it will send the request to the specified pool - P-CSK_NET_5001 right ?

      2)In which scenrio we would require to change the host haeder , whar are we going to achive with that ? 

       

       

  • I am not aware about application, so not able to exact explain about situations. Suggest to connect with application owner/senior who has written iRule.

  • Hi

    if {([string tolower [HTTP::host]] equals "csk-net-corp.aci.network")}{

    HTTP::header replace Host "csk-net-bw.aci.network"

    >> In condition above some server require specific host name, We have to rewrite host name before send to servers

    if { [HTTP::path] starts_with "/test/network" } { pool P_CSK_NET_5001

    >> in condition above F5 check path that start with "/test/network" and forward to pool P_CSK_NET_5001

     

    I hope this information will help you