Forum Discussion

Kamalpreet_1068's avatar
Kamalpreet_1068
Icon for Nimbostratus rankNimbostratus
Aug 24, 2012

Node Selction based on Host Header

Hi ,

 

 

This is the first time i am writting here

 

I have the following scenario

 

Client sends a data to Virtual IP and having a host header "xsp-tibapp-qa-nlb.pac.com:8100"

 

Application is very specific about Host headers

 

On Server 1 - It understand Host header "xsp-tibapp-qa1.pac.com:8100"

 

On Server 2 - It Understand Host Header "xsp-tibapp-qa2.pac.com:8100"

 

I have written a Irule which can change the host header value

 

But the problem is i cannot load balance the traffic.

 

I want if i change the host header to "xsp-tibapp-qa1.pac.com:8100" it should go to Server 1

 

and if i cange it to "xsp-tibapp-qa2.pac.com:8100" it should go to Server 2

 

Irule is as follows

 

when HTTP_REQUEST {

 

 

if { [HTTP::host] equals "xsp-tibapp-qa-nlb.pac..com:8100"} {

 

HTTP::header replace "Host" "xsp-tibapp-qa1.pac.com:8100"

 

use node server1

 

}

 

}

 

 

 

 

 

 

 

 

1 Reply

  • e.g.

    [root@ve10:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.19.79:80
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve10:Active] config  b pool foo list
    pool foo {
       members {
          200.200.200.101:80 {}
          200.200.200.102:80 {}
       }
    }
    [root@ve10:Active] config  b rule myrule list
    rule myrule {
       when LB_SELECTED {
       HTTP::header replace Host [class match -value [LB::server addr] equals host_class]
    }
    }
    [root@ve10:Active] config  b class host_class list
    class host_class {
       {
          "200.200.200.101" { "xsp-tibapp-qa1.pac.com:8100" }
          "200.200.200.102" { "xsp-tibapp-qa2.pac.com:8100" }
       }
    }
    
     200.200.200.101
    
    [root@ve10:Active] config  ssldump -Aed -nni 0.0 port 80
    New TCP connection 1: 172.28.19.251(44440) <-> 172.28.19.79(80)
    1345878448.9086 (0.0010)  C>S
    ---------------------------------------------------------------
    HEAD /something HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
    Accept: */*
    Host: xsp-tibapp-qa-nlb.pac.com:8100
    
    ---------------------------------------------------------------
    
    New TCP connection 2: 200.200.200.10(44440) <-> 200.200.200.101(80)
    1345878448.9094 (0.0006)  C>S
    ---------------------------------------------------------------
    HEAD /something HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
    Accept: */*
    Host: xsp-tibapp-qa1.pac.com:8100
    
    ---------------------------------------------------------------
    
     200.200.200.102
    
    [root@ve10:Active] config  ssldump -Aed -nni 0.0 port 80
    New TCP connection 1: 172.28.19.251(44441) <-> 172.28.19.79(80)
    1345878480.0076 (0.0010)  C>S
    ---------------------------------------------------------------
    HEAD /something HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
    Accept: */*
    Host: xsp-tibapp-qa-nlb.pac.com:8100
    
    ---------------------------------------------------------------
    
    New TCP connection 2: 200.200.200.10(44441) <-> 200.200.200.102(80)
    1345878480.0086 (0.0009)  C>S
    ---------------------------------------------------------------
    HEAD /something HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
    Accept: */*
    Host: xsp-tibapp-qa2.pac.com:8100
    
    ---------------------------------------------------------------