Forum Discussion
F5 irule: HTTP_REQUEST switch -glob HTTP::uri not working with pool
Hi,
I am trying to use a HTTP request iRule to loadbalance from a virtual IP.
If I add the pool directly to the VIP as a default pool; it displays fine.
When I try the below iRule it doesn't load balance to the pool, if I change the below to display a 220 html message after I enter example.com/test1 it works.. Can someone point me in the right direction to what my problem could be?
when HTTP_REQUEST { switch -glob [HTTP::uri] {
"/test1" { pool test_pool } } }
Also, the pool is on a different port than the original HTTP request. The VIP has both address & port translation ticked.
Thanks
- VernonWellsEmployee
This works correctly for me. I recommend checking /var/log/ltm to see if there is an error on the request. If not, add some logging, as in:
when HTTP_REQUEST { log local0. "uri = [HTTP::uri]" switch [HTTP::uri] { "/test1" { log local0. " ... matched" pool test_pool } default { log local0. " ... did not match" } } }
It would fail if the request-uri has something else in it or if the pool no longer exists.
For what it's worth, if this is the only match case, then switch isn't necessary (you can use if), the -glob isn't needed and degrades performance slightly, and you should consider using HTTP::path rather than HTTP::uri so that the expanded string is smaller, as in:
when HTTP_REQUEST { if { [HTTP::path] eq "/test1" } { pool test-pool } }
And, of course, if you are using 11.4+, you may consider using a Local Traffic Policy instead:
- fr55tam_245172NimbostratusThank you! The logging is showing as matched but pool does not load? As I mentioned above when I set this pool to default & hit the VIP over http, it loads fine? Could you assist further? Forgot to mention I will have additional pools that are going to be used depending on the HTTP URI
- VernonWellsEmployee
Is there any information in the logs?
Which version of BIG-IP are you running?
Can you send supply the output of tmsh list ltm virtual where is the name of the VS in question?
When you submit the command output, make sure to add it in the "answer" dialog, and wrap it between a set of code markup delimiters (on DevCentral, that is ~~~ followed by a newline, followed by your content, followed by ~~~ and a newline after that). This makes it much easier to read.
- fr55tam_245172NimbostratusThanks I will get this uploaded, but it does load the pool member when I set it to the default app pool? Only when I use irule it doesn't work.
- VernonWellsEmployee
Perhaps I don't understand what you mean. On the Virtual Server, you assign a default pool. Let's call that pool-default. Naturally, without an iRule, you should see traffic forwarded to members of that pool. When you apply the iRule, you say "it does not load". What do you mean by that? Do you mean it does not forward the traffic to any pool member? What happens when you simply set the pool on the Virtual Server to test_pool? Does it load balance traffic to members of that pool?
If it does not, are any of the pool members marked as "up" by the pool (or node-specific) monitor(s)?
If pool members are up, but traffic forwarding does not appear to be happening, do the pool members of test_pool have the BIG-IP in their default route path? If not, are you using SNAT on the Virtual Server?
- fr55tam_245172Nimbostratus
Thanks for your prompt responses, maybe I'm not detailing my problem enough..
When the iRule is entered it doesn't forward traffic to any of my pool members, they are marked up..
When I set the virtual server to test_pool it loads the pool member fine to a different port than http. Snat is used on the VS with a snat pool, default route path is fine as it works OK when test_pool is set as default pool.
Its very strange that no pool members load with mentioned irule.
- VernonWellsEmployee
Firstly, is there anything in /var/log/ltm when you use the iRule?
If not, I recommend that you associate the iRule and run a packet capture on the BIG-IP:
You will want to dump against the interface 0.0, which is the logical cross-connect between the switch and forwarding plane (or you can use any, which, on more recent versions of BIG-IP, is synonymous). You may choose to use limiters, as in:
tcpdump -nni 0.0 -s0 host or '(host and port ')
This will also capture any monitor traffic for the pool member, so you may wish to temporarily change the monitor to gateway_icmp.
- fr55tam_245172NimbostratusThank you, I will try this, the only detail in my log when using the irule is of the log details you mentioned in the first post, they work successfully but no reference to the pool. I assume you still want me to run this?
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