Forum Discussion
redirect to specific pool based on host
Hi,
I am looking for a Irule to redirect trafic to a specific pool based on the incomming http request host.
I have made the following but the Big IP gaves an error.
when HTTP_REQUEST { if { [HTTP::host] == "linked.jan.nl" } { pool p_sfb_a } elseif { [HTTP::host] == "lyncdiscover.jan.nl" } { pool p_sfb_a } elseif { [HTTP::host] == "owas.jan.nl" } { pool p_sfb_a } else { pool Pool_none } }
Anyone a idea to help me out?
The pools are not jet in place.
This is the message i get from the big-IP when i tried to save the irule.
01070151:3: Rule [/Common/mzi_sfb_redirect_based_on_host] error: /Common/mzi_sfb_redirect_based_on_host:4: error: [undefined procedure: elseif][elseif { [HTTP::host] == "lyncdiscover.maasstadziekenhuis.nl" } { pool p_sfb_a } ]
/Common/mzi_sfb_redirect_based_on_host:10: error: [undefined procedure: else][else { pool Pool_none }]
3 Replies
- jgranieri
Nimbostratus
I recommend you use HTTP Policies in LTM. this basically is a method to make irules like the one your doing very easy in the GUI. I recommend you create a ltm policy with rules for the host value and forward it to a certain pool. Let me know if this helps out.
- Daniel_Varela
Employee
I just have paid your code in my big-ip and it worked. What version are you using? I'd only change '==' by 'eq' as you expect string to be compare it should be a bit effective.
- Stanislas_Piro2
Cumulonimbus
As proposed by jgranieri, the easiest and best solution is to use Local traffic policies.
If you want to use irules, the switch command is better than if / then / elseif / elseif ...
when HTTP_REQUEST { switch [HTTP::host] { "linked.jan.nl" { pool p_sfb_a } "lyncdiscover.jan.nl" { pool p_sfb_b } "owas.jan.nl" { pool p_sfb_c } default { pool Pool_none } } }
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