Forum Discussion

Sam153_178384's avatar
Sam153_178384
Icon for Nimbostratus rankNimbostratus
Dec 08, 2014

iRule not working [redirect to different pool]

Hi, I have VIP in which I have used iRule which redirect one URL to different pool except default. But when I hit URL default pool is being called . Please suggest what is wrong with iRule ?

 

Here is iRule :

 

when HTTP_REQUEST { switch [HTTP::host] { test.com { pool DMZ_a_pool } abc.test.com { pool DMZ_b_pool } default { pool DMZ_a_pool} } }

 

23 Replies

  • Are you saying when you go to abc.test.com you aren't getting pool DMZ_b_pool? Try putting the Hosts into quotes. Also, are you sure your HTTP::host doesn't have :80 or :443 possibly. You can try using "switch -glob [HTTP::host]" to account for that.

     

  • Yes I am not getting to pool DMZ_b_pool when I go to abc.test.com. I do have :80 and :443 VIP.

     

  • the irule looks okay to me.

    i think it may be helpful if you can capture packet. if you do not do snat, tcpdump with client ip filter should be enough.

    e.g.

     tcpdump -nni 0.0:nnn -s0 -w /var/tmp/output.pcap host x.x.x.x -v
    x.x.x.x is client ip
    
  • As suggested by brad by putting the Hosts into quotes should resolve my problem ? e.g "switch -glob [HTTP::host]"

     

    OR

     

    when HTTP_REQUEST { "switch -glob [HTTP::host]" { test.com { pool DMZ_a_pool } abc.test.com { pool DMZ_b_pool } default { pool DMZ_a_pool} } }

     

  • i think Brad suggested something like this.

    when HTTP_REQUEST { 
      switch -glob [HTTP::host] { 
        "test.com*" { pool DMZ_a_pool } 
        "abc.test.com*" { pool DMZ_b_pool } 
        default { pool DMZ_a_pool} 
      } 
    }
    
  • i think Brad suggested something like this.

    when HTTP_REQUEST { 
      switch -glob [HTTP::host] { 
        "test.com*" { pool DMZ_a_pool } 
        "abc.test.com*" { pool DMZ_b_pool } 
        default { pool DMZ_a_pool} 
      } 
    }
    
    • Sam153_178384's avatar
      Sam153_178384
      Icon for Nimbostratus rankNimbostratus
      Ok .. Tell me one thing asterisk part is mandatory for this iRule ? e.g "test.com*" means "test.com" was not enough to do what I am looking for ?
  • I have to apply suggested iRule in our production environment that's why I am asking such questions so that chances of issue should be minimized.

     

    • Sam153_178384's avatar
      Sam153_178384
      Icon for Nimbostratus rankNimbostratus
      Ok I'll share tcpdump result with you today .If you have no issue give me your email ID so that i'll contact with you directly.
    • nitass's avatar
      nitass
      Icon for Employee rankEmployee
      i am at nitass at f5 dot com. feel free to drop me an email and i will get back to you as soon as i can.
  • How about responding back with something to tell you what BIG-IP thinks the Host header is?

     

    when HTTP_REQUEST {
      if {[HTTP::header exists "WTF"]} {
        HTTP::respond 200 content "HTTP host looks like [HTTP::host] \n" noserver Content-Type text/plain pragma no-cache
        TCP::close
        return
      }
      ... rest of your code ...
    }

    Then, use curl -H 'WTF: wtf' to get a response.