Forum Discussion

William_Murphy1's avatar
William_Murphy1
Icon for Nimbostratus rankNimbostratus
Nov 17, 2006

choosing pool based on port in HOST part of HTTP header

Hi,

 

newbie here again but attempting some of this stuff anyway.

 

Trying to write an irule where the pool is decided by what is in the HTTP Header(i.e. HOST: george.george.net:8002)

 

The request will come with 3 possible ports 8002,8003,8004.

 

 

This is what i have written. I have left MMF_pool8002 to last because i want anything that doesnt match the 8003 or 8004 to go to this pool(i.e. MMF_pool8002).

 

 

Am I close? Or any tips

 

 

when HTTP_REQUEST {

 

set redirectPort [getfield [HTTP::host] ":" 2]

 

if { $redirectPort equals "8003" }{

 

pool 8003

 

}else if {$redirectPort equals "8004" }{

 

pool pool8004

 

} else {

 

pool pool8002

 

}

 

}

 

 

Please help man in desparation!

 

 

 

3 Replies

  • Is the rule working? It looks functionally correct. The only question I have is: is the field you're saving from the host header correct? Try logging the value you get for redirectport and checking the /var/log/ltm log file to verify it's what you expect.

     

     

    when HTTP_REQUEST {

     

    set redirectPort [getfield [HTTP::host] ":" 2]

     

    log local0. "port: $redirectPort"

     

    if { $redirectPort equals "8003" }{

     

    pool 8003

     

    }else if {$redirectPort equals "8004" }{

     

    pool pool8004

     

    } else {

     

    pool pool8002

     

    }

     

    }

     

     

    Aaron
  • Hi aron,

     

    I have not tested it yet but put it together. The line i am looking to manipluate in the http header looks like this.

     

     

    "Host: george.george.net:8002"

     

     

     

    I need to extract the port from this to determine pool.

     

     

    What u think?

     

     

    Will
  • Yep, that works:

     

     

    log output...

     

     

    Host header: 172.29.0.219:80 getfield result: 80

     

     

    Aaron