Forum Discussion
iRule to Forward Traffic Based on URL Name
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.
Help on this is appreciated
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
}
}
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
- Manu_NairCirrus
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.
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.
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 - https://support.f5.com/csp/article/K13452
Hope it helps!
- Manu_NairCirrus
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.
Additionally, you can add rules as URIs and pool members do you have.
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
}
}- Manu_NairCirrus
Thanks for this information. I will try with this.
- SeçkinCirrus
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
- Manu_NairCirrus
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.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com