Forum Discussion

Manu_Nair's avatar
Icon for Cirrus rankCirrus
Feb 22, 2022

iRule to Forward Traffic Based on URL Name


I am in a situation where we have shortage of IP address and am looking for an alternative way to forward traffic to pools based on URL. I am not really good with iRule hence looking for assistance and I have seen posts based on URI, but i am looking for assistance with URL

Eg: 1 VIP and based on the url name, the traffic needs to be forwarded to Pool. 

Help on this is appreciated

  • Hi 

    below irule will help

    when HTTP_REQUEST {
      if { ([string tolower [HTTP::host]] eq "host1") {
            pool pool1
        } elseif { ([string tolower [HTTP::host]] eq "host2")  {
            pool pool2

10 Replies

  • Hello,

    For this purpose, i would go for LTM Policy over irule. Its very easy to implement and also you dont need to know programming language to do it.



    • Manu_Nair's avatar
      Icon for Cirrus rankCirrus

      Thanks for the reply Seckin, I am new this Policy type as well, But i did not what parameter to keep, but looks i got few suggestions to use Policy. I will try it out. 

  • You can use LTM Policies that are in the document that I shared with you before, which is the best way to make this type of deployment without irules.


    • Mayur_Sutare's avatar
      Icon for MVP rankMVP

      Hi Manu_Nair ,

      Modified LTM policy as per your use case. You can have such multiple rules to match based on the URL under a LTM policy.

      iRule given by neeeewbie is also perfect for your use case. One more thing that I want to highlight here is that if you have different domains which will hit on single virtual server with secured port, you would need to handle SSL certiifcates appropriately so for each URL/Site, client will get desired certificate. For this, you need to configure F5 vServer to serve multiple HTTPS sites using the TLS SNI feature. 

      Ref. article - 


      Hope it helps!

      • Manu_Nair's avatar
        Icon for Cirrus rankCirrus

        Hi Mayur, 

        Thanks for the reply!!  I got the certs and other stuff ready. Just was struggling to get this done cos i am not sure what parameter to pass ( eg : HTTP Host ). i will try this with policy and see. 

    • Manu_Nair's avatar
      Icon for Cirrus rankCirrus

      Thanks for the reply, but what the guide shows there is to forward traffic based on the URI (or path). I am looking specifically for different hostnames(URL names) which i am not sure what they call in the irule, http host or header???  so i am not clear how to achive this. 

      Need to extract the URL name through irule and based on the name, forward it to the pools.