Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

Rewrite Host Header i-rule question

Hi all. I'm interested in changing the Http host header when an http request occurs. I searched a little bit and I found out that this can be achieved by using an i-rule.For example.

when HTTP_REQUEST {
if { [HTTP::host] eq "test1.image.com" } {
HTTP::header replace Host "www.image.com"
}
}

or

when HTTP_REQUEST { 
if { [HTTP::header host] eq "test1.image.com" } {
HTTP::header replace Host "www.image.com"
}
}

I don't know which of the above will do the trick for me.The outcome of the above will be that the client will have on his internet browser bar www.image.com appeared ? In case the answer is yes then everything will be ok. In case the answer is no then I assume that a header replacement will be needed as well on the http response. I know the answer is simple nut I have no access on a lab env atm and Im stuck. Thanks

0
Rate this Question
Comments on this Question
Comment made 10-Oct-2017 by Daniel Varela 711

I don't think there is a way to change the url in the browser but sending back a redirect to the client. Host header rewrite is intended to rewrite this header on its way to the back-end server so you can show them a diferent host if that's the requirement.

0

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

When a client accesses the URL for the first time, what address will they use?

Typically you'd want your clients to connect on www.image.com (resolved by public DNS) If the HTTP response, from your internal servers contain a header different to the request. You can replace the header on response. This way your clients will only see www.image.com in the address bar.

0
Comments on this Answer
Comment made 13-Oct-2017 by HG 341

Hi all.This i-rule worked good in my case.The scenario is that servers can accept requests for image.com but public IP is associated to test1.image.com. Thus, in order for servers to respond , [HTTP::host] header should be image.com. By replacing the header on the request everything worked good. In other words, client types test1.image.com which is replaced with image.com when the request reaches the server. I was thinking if that may cause any issues with the response but everything worked like a charm. Probably this replacement takes place as well on the response for relative paths.

0