Forum Discussion
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
- Brad_Parker
Cirrus
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.
- Sam153_178384
Nimbostratus
Yes I am not getting to pool DMZ_b_pool when I go to abc.test.com. I do have :80 and :443 VIP.
- nitass
Employee
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 - Sam153_178384
Nimbostratus
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} } }
- nitass_89166
Noctilucent
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} } }- Brad_Parker
Cirrus
That's what I was thinking.
- nitass
Employee
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} } }- Brad_Parker
Cirrus
That's what I was thinking.
- Sam153_178384
Nimbostratus
Ok thanks.. Should I try this ?
- nitass
Employee
of course if you would like. :-) - Sam153_178384
Nimbostratus
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 ? - Sam153_178384
Nimbostratus
is there business justification for putting * in iRule ?
- Sam153_178384
Nimbostratus
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
Nimbostratus
Nitass,
I have tested the irule but no success : ( Please suggest
- nitass
Employee
can you try tcpdump? - Sam153_178384
Nimbostratus
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
Employee
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.
- Sean_Ellis_9378
Nimbostratus
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.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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