Forum Discussion

Robert_47833's avatar
Robert_47833
Icon for Altostratus rankAltostratus
Aug 07, 2011

HTTP::header replace Host and HTTP:redirect

Hi,dear irule

 

1:if there are rule1 and rule2 under one VS,order is rule1 and rule2

 

rule1:

 

when HTTP:request {

 

if { [HTTP::host] euqals "www.srwd18.com"} {

 

HTTP::redirect "http://www.baidu.com"

 

}

 

}

 

 

rule2

 

when HTTP::request {

 

if {[HTTP::host] equals "www.srwd18.com"} {

 

HTTP::redirect "http://www.google.com"

 

}

 

}

 

 

so if someone visit www.srwd18.com,client will go to www.google.com or where?

 

how to turn off rule2,I only know return will jump out of the current event in single irule.

 

 

2:if I use HTTP::header replace Host "www.baidu.com" to rewrite the request

 

it seems this will not change the item in broswer,such as IE

 

 

so bigip will visit www.baidu.com for client,right?like a proxy

 

 

when HTTP::REQUEST {

 

if {[HTTP::host] equals "www.srwd18.com"}{

 

HTTP::header replace Host "www.baidu.com"

 

return}

 

}

 

it doesn't work

 

 

overall:What I am trying to achieve is:

 

there are 2 datacenter, same website ,if I want to forward traffic in site1 to site2 ,how to forward them?

 

The only way I can think about is HTTP::REDIRECT,but this will change the item/address in client's broswer

 

so it seems HTTP::header replace Host is a good choice,

 

Can some one help me?

 

Thanks in advance,

 

14 Replies

  • besides this, when HTTP_REQUEST {

     

    log local0.info "rule1"

     

    if {[HTTP::host] equals "www.srwd18.com"} {

     

     

    node 220.181.111.147 80

     

    HTTP::header replace Host "www.baidu.com"

     

    }

     

     

    only can send http request to site2 ,if no ssl server profile set in VS of site1,it will not work

     

    do we will have cookie issue if we use http::header replace?

     

  • Can u give me the process how bigip handle this? HTTP::header replace Host "www.baidu.com"

     

    it seems there is no http 302 or something like this

     

    i have seen Colin has answered this question there.

     

    http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/1179184/showtab/groupforums/Default.aspx

     

     

    and there are 2 FTP VS,how to redirect them?

     

    i think the problem is how we get ftp hostname (since u want to redirect to site2 based on the hostname).

     

     

    this is tcpdump when i connected to ftp server.

     

    220 (vsFTPd 2.0.6)

     

    USER anonymous

     

    331 Please specify the password.

     

    PASS

     

    230 Login successful.

     

    PORT 192,168,206,96,202,69

     

    200 PORT command successful. Consider using PASV.

     

    NLST

     

    150 Here comes the directory listing.

     

    226 Directory send OK.

     

     

    this is one of discussion topics i have found.

     

    http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/25911/showtab/groupforums/Default.aspx

     

     

    only can send http request to site2 ,if no ssl server profile set in VS of site1,it will not work

     

    do we will have cookie issue if we use http::header replace?

     

    sorry i could not understand. can u post your virtual config here?
  • only can send http request to site2 ,if no ssl server profile set in VS of site1,it will not work

     

    do we will have cookie issue if we use http::header replace?

     

     

     

    sorry i could not understand. can u post your virtual config here?

     

    ------for example ,in site 1 , there is a VS which only has client side ssl profile ,same as VS in site2

     

    if I use

     

    if {[HTTP::host] equals "www.srwd18.com"} {

     

    node 220.181.111.147 80

     

    HTTP::header replace Host "www.baidu.com"

     

    then plain text will be sent to site2,because I don't have ssl server side profile.

     

  • Hi,nitass

     

    do we have command to redirect ftp VS?

     

    I know the hostname ,it is static

     

    thanks in advance