Forum Discussion
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.
- BobowJul 25, 2023Cirrus
- PauliusJul 25, 2023MVP
Bobow Hopefully this works but as whisperer stated, just because it works doesn't mean it's the appropriate course of action. You are better off allowing the destination servers to handle this rather than the F5 using some bandage method that will most likely cause huge problems for you in the future.