Forum Discussion
Add a prefix before sending the request to the Pool
Hi,
Scenario :
A single VS (3.3.3.3) with two different Pool based on the URI prefix :
Pool A: the member web server 1.1.1.1 is configured on a Virtual Directory /web
Pool B: the member web server 2.2.2.2 is configured on a Virtual Directory /reports
Requirement:
Client browser must connect to the root directory of the Virtual Server and the LTM will use Pool A and add the /web prefix before sending the request to the Pool except /reports which the LTM will use Pool B and pass through the URI with no changes
Example:
- http://3.3.3.3/ <==> use Pool A <===> http://1.1.1.1/web
- http://3.3.3.3/image <==> use Pool A <===> http://1.1.1.1/web/image
- http://3.3.3.3/reports <==> use Pool B <===> http://2.2.2.2/reports
- http://3.3.3.3/reports/pdf <==> use Pool B <===> http://2.2.2.2/reports/pdf
Can someone kindly enough to build the irules that meet the requirement above ?
Many thanks in advance.
Adrian.
5 Replies
- Adrian_P
Nimbostratus
Hi Scott, I typed my questions in the text editor and use markdown format. I am using Chrome Browser Version 28.0.1500.95 - Anthony_Graber
Employee
when HTTP_REQUEST { if {[HTTP::uri] starts_with "/reports"}{ pool pool_b } else { HTTP::uri /web[HTTP::uri] pool pool_a } }OR
when HTTP_REQUEST { if {[string tolower [HTTP::uri]] starts_with "/reports"}{ pool pool_b } else { HTTP::uri /web[HTTP::uri] pool pool_a } } - Kevin_Stewart
Employee
You'll probably also want a OneConnect profile assigned to the VIP.
- nitass
Employee
just in case you have not yet seen this solution.
sol9800: Using an iRule to load balance HTTP requests to multiple pools
http://support.f5.com/kb/en-us/solutions/public/9000/800/sol9800.html
- Adrian_P
Nimbostratus
Thank you very much for all the help.
I have finally get it working and here is the final irules that I use. I add some log command as a troubleshooting tool to log the variable in the /var/log/ltm
Add /web prefix Unless it started with /reports when HTTP_REQUEST { log local0. "in HTTP_REQUEST" set orguri [HTTP::uri] log local0. "Original: $orguri." if {[string tolower $orguri] starts_with "/reports"} { pool pool_b } else { set newuri "/web[HTTP::uri]" HTTP::uri $newuri pool pool_a } log local0. "After mapping: [HTTP::uri]" log local0. "Pool: [LB::server pool]" }
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