cancel
Showing results for 
Search instead for 
Did you mean: 

iRule to Forward Traffic Based on URL Name

Manu_Nair
Cirrus
Cirrus

Hi,

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. 

Manu_Nair_0-1645534082169.png

Help on this is appreciated

1 ACCEPTED SOLUTION

neeeewbie
MVP
MVP

Hi 

below irule will help

https://support.f5.com/csp/article/K27803480

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

View solution in original post

10 REPLIES 10

Sebastiansierra
Cirrostratus
Cirrostratus

Hi,

You have two options, irules or LTM policies, follow the next article that guides you in the configuration:

https://f5-agility-labs-adc.readthedocs.io/en/latest/class3/module6/lab6.html

 

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. 

Sebastiansierra
Cirrostratus
Cirrostratus

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.

Sebastiansierra_0-1645551560785.png

 

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.

F5 LTM Policy to forwards Traffic based on the URL or Hostname.JPG

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 - https://support.f5.com/csp/article/K13452 

 

Hope it helps!

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. 

Sebastiansierra
Cirrostratus
Cirrostratus

Additionally, you can add rules as URIs and pool members do you have.

neeeewbie
MVP
MVP

Hi 

below irule will help

https://support.f5.com/csp/article/K27803480

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

Thanks for this information. I will try with this. 

Seckin
Cirrus
Cirrus

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.

Regards

Seçkin

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.