Forum Discussion

HG's avatar
HG
Icon for Cirrus rankCirrus
Oct 10, 2017

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 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

  • 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.

     

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

     

    Typically you'd want your clients to connect on (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 in the address bar.