Forum Discussion
iRule for load balancing to different virtual server depending on the URI path
Your description is hard to follow. Can you please provide a flow chart for how you want the different URIs to map to what paths / locations / IPs? Or perhaps a better flow to facilitate understanding of the issue.
- PauliusJul 25, 2023MVP
Bobow This might work but what you are attempting to do seems a whole lot more complicated this way and can most likely be done cleanly by only matching the URI path to a specific destination VS rather than letting load balancing occur and then changing the HOST and URI path after the fact.
when LB_SELECTED priority 500 { set SELECTED_POOL_MEMBER[LB::server addr] } when HTTP_REQUEST_SEND priority 500 { if { ${SELECTED_POOL_MEMBER} == vs_b_ip } { HTTP::uri [string map {"/aa" "/"}[HTTP::uri]] HTTP::host [string map {"test.com" "test1.com"}[HTTP::host]] } elseif { ${SELECTED_POOL_MEMBER} == vs_c_ip } { HTTP::uri [string map {"/aa" "/"}[HTTP::uri]] HTTP::host [string map {"test.com" "test1.com"}[HTTP::host]] } }
As many have said before "Just because it can be done with an iRule doesn't mean you should." so you might want to look at alternatives that work a bit better. For instance you might consider allowing the servers to listen for the orignal host and uri rather than mapping strings to assist in resolving the issue.
- whispererJul 25, 2023MVP
If the web servers use absolute paths with an internal host name or something similar, I can see why the F5 has to rewrite this on the server side of the connection. Also, if the web server doesnt support virtual hosting. Well, if either of those cases are true.... it is 2023 last time I checked. Either a) update the web server technology or b) force the web app developers to write better code. I would not use such a hack job to make this work for the sake of making it work. The complexity will result in other things breaking. Been there, done that.
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