Forum Discussion
URI based pool selection
Hi,
I have a requirement to forward particular URIs to different pools as per the following:
---> backend_server_address:8080
--->backend_server_address:8082
To implement this forwarding I used the below iRule: pool0=backend_server_address:8080 pool1=backend_server_address:8082
when HTTP_REQUEST {
set my_uri [string tolower [HTTP::uri]]
if {$my_uri starts_with "/abc" } {
pool pool1
} else {
pool pool0
}
}
When I access the backend server directly using it will redirect me (HTTP/301) to where the page is displayed.
However when this is tested through F5 LTM using the above iRule, the page is requested from the backend server using but the redirect is not happening instead I am getting a 404 since /abc is not a physical directory on the backend server.
Any idea why the virtual server is not following the same redirection as a normal client accessing the site.
Thanks, Rami
```
3 Replies
- Michael_Jenkins
Cirrostratus
Does your backend server expect any specific host header on the request?
Also, if you have CLI access, you could try using
to test that uri from the F5 box. Something likecurl
. That should give you the same experience as testing from your local machine as you mentioned getting the 301. What response do you get from that?curl -vvv http://backend_server_address:8082/abc - ramig_184705
Nimbostratus
I tried to access the website using curl from the CLI, it gives the 301.
The backend server is set to accept any host header (*).
- THi
Nimbostratus
Your iRule is selecting the pool based on the existence of /abc in the request. It does not alter the request itself. So forwarding to pool1 with uri /abc. Now if I understood right this path does exist on the backend server and it will do a redirect to /. Which will result as a new request. Should you actually change the uri at the BIG-IP itself instead of the backend server?
The new request may be the culprit, based on the way BIG-IP handles http requests. Do you have OneConnect on? As a default, without OneConnect profile enabled, the iRule is triggered on the first request and on subsequent requests the traffic goes to the pool selected on the first one. If you have one connect enabled, then the iRule is evaluated on all requests and the iRule will parse and select pool0. There are ways of enabling OneConnect behaviour within the iRule, too (LB::detach etc).
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