Forum Discussion

Rajesh_Ojha_355's avatar
Rajesh_Ojha_355
Icon for Nimbostratus rankNimbostratus
Mar 19, 2018

Need help for replacing header in HTTP_RESPONSE

We are using F5 as the proxy server between client and destination. We need to replace the Host of a URL in both forward and reverse flow. Forward case is working as expected, but Reverse doesn't seem to replace. Any suggestions would be greatly appreciated. Also can you suggest a way to add log debug statements to print the header after it gets replaced in the log?

 

  1. Forward: From Client as "service-t-client.com" to destination "service-2.destination.com"
  2. Reverse: From destination "service-2.destination.com" to Client "service-t-client.com"

iRule is as follows:

 

when HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { "service-t-client.com" { HTTP::header replace Host "service-2.detination.com" } } }

 

when HTTP_RESPONSE { foreach header {"service-2.destination.com"} { HTTP::header replace Host "service-t-client.com" } }

 

2 Replies

  • Hi

     

    In your HTTP_RESPONSE code you are looking for a header called service-2.destination.com rather than looking for a header value.

     

    Does something like this work?

     

    when HTTP_RESPONSE {
    
    if {[HTTP::header "Host" equals "service-2.destination.com" } {
    
    HTTP::header replace Host "service-t-client.com"
    }
    
    }