cancel
Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.

Need Help to create an iRule for Name Based Virtual Hosting

girishb
Cirrus
Cirrus

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 10.1.1.1443 it needs to then route to either 1perf.cloud123.com and 1perf.cloud123.com and so on.

 

VIP-PRF -> VIP

 

VIP-PRF _POOL -> Pool Members

 

             10.1.1.1:0 -> Legacy

             10.1.1.2:0 -> Legacy             

             

             10.1.1.3:443 -> New tomcat

               1perf.cloud123.com -> Instance of the new application

               3perf.cloud123.com-> Instance of the new application 

                            

             10.1.1.4:443 -> New tomcat

             2perf.cloud123.com -> Instance of the new application

               4perf.cloud123.com-> Instance of the new application

 

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

https://devcentral.f5.com/s/articles/name-based-virtual-hosting-with-ltm)

 

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

 

Great thanks in advance

 

2 REPLIES 2

Samir
Nacreous
Nacreous

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_A[ 1perf.cloud123.com,   3perf.cloud123.com]

Pool_B [  2perf.cloud123.com,   4perf.cloud123.com]

 

* Create iRule

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

* Create the Virtual Server and assign irule.

 

Hope it will solve issue.

 

girishb
Cirrus
Cirrus

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 10.1.1.3 and  10.1.1.4 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 : 10.1.1.4 should have Header Insertion as   2perf.cloud123.com and   4perf.cloud123.com

and if if URI contains Web1 , Then request goes to 10.1.1.3 then it should have Header insertion as 1perf.cloud123.com and  3perf.cloud123.com.

 

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