Forum Discussion

winifred_corbet's avatar
Icon for Nimbostratus rankNimbostratus
Jan 24, 2011

Replace HOST not working

We have a list of URIs that we added to a data group


For only those URIs in the datagroup, we need to change the Hostname, keeping the URI



This irule attempt is not working. Host name is not changing. What are we missing?






if { [matchclass [string tolower [HTTP::uri]] starts_with $::abunchofURLs] } {


HTTP::header replace Host ""





4 Replies









    We need the client to see the new hostname.



    we did see the log entry,but host name change is not occurring.






  • So, if your rule looks like the below, you're actually seeing the log show up?

    when HTTP_REQUEST {
      if { [matchclass [string tolower [HTTP::uri]] starts_with $::abunchofURLs] } {
       HTTP::header replace Host ""
       log local0. "URI was [HTTP::uri] and host was changed from [HTTP::host] to ""
  • Colin_Walker_12's avatar
    Historic F5 Account
    To be clear, you're just looking to replace the host header, not actually redirect the user so that the browser's URL bar updates, right? If you re-write the host header on the LTM the request should arrive at the correct location but the user will not see the change to the host.



    Quoting the wiki Click Here:



    "To update the Host header value without redirecting the client to the new Host value, you can use HTTP::header replace Host "". 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."



  • A few related possibilities:



    - Are you checking the serverside connection to see the change? As Colin mentioned, the change would be made in the request which LTM proxies to the pool member. If you want the client to see the change, you could use HTTP::redirect to send a redirect instead of rewriting the proxied request's host header.


    - If you're on 9.4.4 or higher, you should remove the $:: prefix from the class name reference in the iRule. In 10.x, this would break the matching.


    - The value for HTTP::host and most other HTTP commands is cached in the same event and event priority. So if you log the value for HTTP::host, change it with HTTP::header replace, and then log the value for HTTP::host again, the cached value will be logged.