Forum Discussion

Abdou76's avatar
Abdou76
Icon for Cirrus rankCirrus
Nov 10, 2022
Solved

Multiple server with one VS

Hello, 

Can i use two différents servers with one virtual server, for example : 

1/ abc.com :

Vs 172.16.250.100 -----> server1 : 10.10.10.10

2/ xyz.com :

Vs 172.16.250.100 -----> server2 : 10.10.10.11.

Thanks you

 

 

  • Abdou76 , 
    sure you can do this , 
    try this : 

    when HTTP_REQUEST { 
     if {[HTTP::host] eq "abc.com"}{ 
      pool pool_1
     } elseif {[HTTP::host] eq "xyz.com"}{ 
         pool pool_2
    } elseif {[HTTP::host] eq "ghl.com"}{ 
         pool pool_3
         } 
    }

    Hope it works with you. 
    Regards 

  • Abdou76's avatar
    Abdou76
    Nov 20, 2022

    Hi mohamedT

    hank you for your great help

     

31 Replies

  • Hi Abdou76 , 
    Yes , it is doable on F5 by two methods LTM Policies or iRule : 
    First : 
    > create two pools , and Put " 10.10.10.10 in pool_1" and "10.10.10.11 in Pool_2". 

    > then , Go to ( Local traffic , Policies ) and follow the below Article , steps to construct you LTM policy : 
    https://techdocs.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/local-traffic-policies-getting-started-12-1-0/1.html

    its quite Long but it is helpful 😀
    - you need to perform such below snap shots : 
    Create two rules in LTM policy : 

    Do not Forget to Publish your Policy to be able to assign it in virtual servers , find below : 

    > assign your LTM policy to your virtual server " 172.16.250.100" 


    > you can do this Task By iRule : 

    when HTTP_REQUEST { 
    if { [HTTP::host] eq "abc.com" } 
    { pool_1} elseif 
    { [HTTP::host] eq "xyz.com" } 
    { pool_2} 
    }

     

    > I recommend LTM policy as it is simpe and light on F5 appliance. 

    I hope this helps you. 

    Regards

    • CA_Valli's avatar
      CA_Valli
      Icon for MVP rankMVP

      Correct answer, just be careful with iRule syntax because putting parenthesis on new lines like that can result in issues - expecially on the elseif statement. Also, pool command is pool <pool_name> 

       

      when HTTP_REQUEST { 
       if {[HTTP::host] eq "abc.com"}{ 
        pool pool_1
       } elseif {[HTTP::host] eq "xyz.com"}{ pool pool_2 } 
      }

       


      I would suggest using LTM policies too, since it uses a configuration template that is better supported during software upgrades, and also typically performs 20% faster.

  • Thanks you for feedback, but thé availability of m'y VS still unknown (blue color) 

     

    • Okay Abdou76 , 

      make sure to assign a monitor to your pools until make them available. 
      Then apply your iRule to your Virtual server. 

      The best way to make it available is assigning a default pool directly , but I Tested it on my lab and I see the virtual server available when " all pools that have been used in irule UP and Available by their health monitor " 

      Try it 
      Regards

      • Abdou76's avatar
        Abdou76
        Icon for Cirrus rankCirrus

        Hi Mohamed

        Bellow are my captures :