Forum Discussion

girishb's avatar
Icon for Cirrus rankCirrus
Jan 25, 2020

Need Help to create an iRule for Name Based Virtual Hosting

We are trying to build iRule for one newly build tomcat server when the F5 picks one of the new pool members, the iRule needs to route the request, in a round robin manner, to the different instances of the application on the same VM/IP.


So for example, when picking it needs to then route to either and and so on.




VIP-PRF _POOL -> Pool Members


    -> Legacy

    -> Legacy             


    -> New tomcat

      -> Instance of the new application

     > Instance of the new application 


    -> New tomcat

    -> Instance of the new application

     > Instance of the new application


We tried create iRules but its not allowing to create ( refering this devcentel link.:


I need your help to create iRule based name based virtual hosting on VIP


Great thanks in advance


2 Replies

  • Hosting multiple websites on the same virtual server and load balancing requests to the appropriate webserver based on the host name requested. This can be achieved via iRule or F5 policy also.

    ** Make sure IP address bind with multiple DNS CNAME.

    * Create the LB Pool based on the application requirement.


    Pool_B [,]

    * Create iRule

    when HTTP_REQUEST {
    set host [string tolower [HTTP::host]]
    switch -glob $host {
          "" {
             pool pool_A
          "" {
             pool pool_B
         default { reject }

    * Create the Virtual Server and assign irule.

    Hope it will solve issue.

  • Hi Samir, Great Thank for your details.. you added correct details :)


    I just wanted to added few more details..


    there is an existing VIP : VIP-PRF, there were two new AWS servers added and to this Pool Member which are Name Based Nodes . so the request here is like no changes should be made to the existing Pool members and for New Pool members we need to have the traffic going :


    if URI contains Web2 then request to the Node : should have Header Insertion as and

    and if if URI contains Web1 , Then request goes to then it should have Header insertion as and


    So backend Server look into this endpoint in server code so later on re-direct further on