Forum Discussion

D_J__Mudde_1907's avatar
D_J__Mudde_1907
Icon for Nimbostratus rankNimbostratus
Apr 06, 2016

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

  • 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 }
        }
    }
    
  • 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.

     

  • 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.