08-Jun-2021 08:45
i want an irule to send traffic to specific node based on header at request
09-Jun-2021 00:34
Hi Mostafa,
Have you already found any iRule that does anything similar to what you need? Have a look in the Codeshare (see links at the top) to find something similar and then tweak it to what you need. Here is an example that should be pretty close to what you need; https://devcentral.f5.com/s/question/0D51T00006i7XSL/host-header-loadbalancing
Alternatively, for this function, Local Traffic Policies are very suitable. In your F5, go to Local Traffic - Policies and create a new policy. You can then use drop-down menus to make Match-Action statements. I'm using these to do load balancing on the Host header myself. (More details: https://techdocs.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/local-traffic-policies-getting-started-12-1-0/1.html)
Hope this helps.
09-Jun-2021 00:42
Thanks for your reply, i can't use LTM policy as the header is not well-known, it is developed by application developer team.
So if i use the below IRule, is that enough to make what i need or not.
when HTTP_REQUEST {
if { [HTTP::header "name"] contains "value" } {
node 192.168.7.180 80
}
}
10-Jun-2021 00:38
Hi Mostafa,
In your iRule, as you are load balancing to a member (IP address plus a port number), rather than a node (IP address only), you should use a different syntax;
pool my_Pool member 10.1.2.200 80
See more details here: https://clouddocs.f5.com/api/irules/pool.html
But yes, for the rest it looks pretty good to me!
Coming back to the LTM policy though, this can also work with non-standard headers, see an example of it below. If you can do it that way, it will be less error-prone but also more efficient to run.