Forum Discussion
URL forwarding to dedicated nodes
Hello,
I am still very new to iRules, and I am trying to get the code correct for a simple URL redirect. I would like to route certain URL-paths to dedicated servers in the same pool.
For example path /foo/ should only go to server "a". Path /bar/ to server "b". And both servers "a" and "b" are in the same pool.
Any help with this will be greatly appreciated:)
Thanks!
- Snl
Cirrostratus
try below (not tested) assume server a - 10.1.1.1 port 8080 & server b 11.1.1.1 port 8080
when HTTP_REQUEST { if { [string tolower [HTTP::uri] ] starts_with "/foo" } { node 10.1.1.1 8080 } elseif { [string tolower [HTTP::uri] ] starts_with "/bar" } { node 11.1.1.1 8080 } }
- CoolPolishGuy
Nimbostratus
Hello,
You could try doing something like the following code
when HTTP_REQUEST { if { [HTTP::path] contains "/bar" } { log local0. "pool_a" pool server_a } elseif { [HTTP::path] contains "/foo"}{ log local0. "pool_b" pool server_b } else { log local0. "pool_default" pool server_default } }
If you want to redirect to specific node inside the pool then write
node 172.x.x.x XXXX
Hope it helps
- Svevak_211593
Nimbostratus
Thank you. Works now :)
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