Forum Discussion

ashk's avatar
ashk
Icon for Cirrus rankCirrus
Sep 15, 2023

iRule for sending traffic to a different pool based on the Hostname.

Team, 

 

I have a virtual server with port 8899 configured as PerformanceLayer4 and FastL4. I am using couple Host names to drive thru this Virtual Server. 

I want to send the traffic to pool_magnus when the traffic is coming with host magnus.com. 

I wrote an Irule as below but its not working I can see the host coming and still going to the default pool. I think the traffic coming is not http traffic its TCP traffic. Need assistance. 🙂 

when HTTP_REQUEST {
set host [string tolower [HTTP::host]]
if { $host eq "magnus.com" } {
pool pool_magnus
}
}

 

  • If it helps, you can do this very quickly in a Policy (LTP)
    When HTTP Host = <Hostname> on Request.
    Forward to "Virtual Server or Pool"
    Its a very simiular concept to vip targetting vip, but its vip targetting many pools.
    I do something very simular with uri's and pools.

  • Hi ashk , 

    - you must add a HTTP profile in your bigip to let it able to parse http requests and understand the meaning of hostnames and headers. 
    you can use the following syntax but after adding http profile first : 

     
     when HTTP_REQUEST { 
      
         #Check requested host header (set to lowercase) 
        switch [string tolower [HTTP::host]] { 
      
           "www.site1.com" { 
              pool site1_pool 
           } 
           "www.site2.com" { 
              pool site2_pool 
           } 
           default { 
              pool default_pool 
           } 
        } 
     } 
     


    - you can use If statement as well. 

    - the most efficiecnt one is to use Local traffic policies , it's light weight on system CPU and it's very easy to implement. 

    I hope this helps you  

  • ashk  - If your issue was resolved please select *Accept As Solution* (may choose more than one)
    Thanks for contributing to our community.

  • appologies every one, I was on OOO and unable to get hold of the system. I had added http profile its accepted the iRule with HTTP_REQUEST and seems like working now. 

    Also, its non HTTP traffic not there is nothing much worked to redirect the traffic. It was not working for non HTTP traffic. I used "when TCP_REQUEST". 

    appreciate the help