questions on HTTP::header replace Host

Hi,dear irule

I have 2 datacenters,due to some operation,we need to forward traffic on site1 to site2

site1 and site2 have the same domain name www.cjj.com

However ,they can be different in order to achieve goal of forwarding traffic

like www1.cjj.com ,www2.cjj.com(I can change something to achieve this)

for example ,clients visit www.cjj.com and hit site1,when bigip receive this traffic ,forward it to site2 and keep the broswer same as before.

how to achieve this?

I searched the irule here,HTTP::header replace Host are used more often than other methods

But I am confused by events below

when HTTP_REQUEST {

if { [HTTP::header host] eq “www.cjj.com” } {

HTTP::header replace Host “www2.cjj.com” }

}

when HTTP_RESPONSE {

if { [HTTP::header is_redirect]} {

HTTP::header replace Location [string map -nocase {www.cjj.com www2.cjj.com} [HTTP::header value Location]] }

}

Here is my doubts:

1:why should we use HTTP_RESPONSE to change the location?

2:should I set node xxx under HTTP::header replace Host “www2.cjj.com”

like

HTTP::header replace Host “www2.cjj.com”

node xxxxip xxport

3:what is the process of this command ,after excuting this replace,what is the behavior of bigip to handle traffic(I know http::redirect is bigip send 30x to client and the client send request to new URL )

4:how to achieve this goal :forward traffic which hit site1 to site2 ,can I not need two domain name to achieve this?

Thanks in advance

Hi Jucao,

You would want to to use HTTP_RESPONSE so that the client’s browser redirects to the site2, preserving the URI on the browser. Setting the node to site 2 will basically mean to connect to site2 you need to connect through site 1 LTM potentially adding latency to the client.

The following is an excellent article on HTTP Redirects and their many different ways to accomplish this with specific results

http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/220/Rewriting-Redirects.aspx

I hope this helps

Bhattman

Hi,Bhattman,good to see u again

1:if I set replace in HTTP_RESPONSE,what will bigip ip do

we don’t want the HTTP_REQUEST to process the connection ,just when receive request,forward it to site2,but in this way,I think traffic will be handled by HTTP_REQUEST first

2:sorry for my bad understanding,you mean

when HTTP_REQUEST {

if { [HTTP::header host] eq “www.cjj.com” } {

HTTP::header replace Host “www2.cjj.com”

nod xxxip xxport }

} is not good?

what is the action bigip will do if I set this HTTP_REQUEST

when HTTP_RESPONSE {

if { [HTTP::is_redirect] }{

HTTP::header replace Location [string map {“A.internal.com” “X.external.com”} [HTTP::header Location]]

}

} is a method to change the location when there is a redirect

Actually in my case,there is no redirect,we need to generate a redirect…

Hi,I want a irule to proxy site2 via site1

2:sorry for my bad understanding,you mean

when HTTP_REQUEST {

if { [HTTP::header host] eq “www.cjj.com” } {

HTTP::header replace Host “www2.cjj.com”

nod xxxip xxport }

} is not good?

yes, Bhattman means it will add latency to client since traffic has to travel to site1 first and then site2. if u use HTTP::redirect, cilent will connect to site2 directly but uri in his browser will also be changed.

when HTTP_RESPONSE {

if { [HTTP::is_redirect] }{

HTTP::header replace Location [string map {“A.internal.com” “X.external.com”} [HTTP::header Location]]

}

} is a method to change the location when there is a redirect

yes

Hi,

but there is no redirect now,

Can we generate a redirect ?

I want to redirect to site2 and keep the old url in browser

Can I achieve this?

Hi,friends

I want to use irule to redirect and use irule to keep old url in browser .It seems it is not possible

No, that’s not possible in HTTP. You can either update the browser with a redirect or rewrite the request and send it through LTM to a destination.

Aaron

Thanks,Aaron

if use rewrite and send it to another site2,there is a problem

VS:with client ssl profile ,without serverside ssl profile

it will send plain text to site2…because it thinks site2 is backend server

You could selectively enable a serverside profile, couldn’t you?

ok,I think this is the only way to achieve this goal even it is too much to do ,need to enable ssl server profile and disable them in some case

Thanks

Yep, that’s the route I’d imagine would be most likely to succeed.

Colin