iRule to Redirect to Another VS on the same LTM
Hi guys - I'm trying to get the following scenario working:
- My domain "; maps to a public IP "1.1.1.1" and I have a virtual server configured on my F5 with "1.1.1.1:443"
- I have two unrelated applications with competing requirements running on different URIs on the same domain , one is a HR application (/abc) and the other is a inventory application (/def)
- I need to create a design which accomodates both applications with a single domain name, and find a way to accomodate both their conflicting requirements under the same domain name
To solve this problem, I thought that I should do something like this, on the main virtual server 1.1.1.1:443, I put in an iRule with the following code:
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with "/abc" } {
virtual VS2
} else if { [string tolower [HTTP::uri]] starts_with "/def" } {
virtual VS3
} else {
HTTP::respond 200 content "Unrecognised URI, please recheck your address"
}
}
This would redirect incoming requests with "/abc" in the URI string to VS2 and incoming requests with "/def" in the URI string to VS3. Then I could create customised solutions for both applications in their respective virtual servers.
So drawing this flow out, I think this is how it would look:
But what I don't understand is how the Return Traffic and the Persistence Profiles work in this scenario.
How do I make sure that the traffic flows this way:
- User to Server: User > VS1 > VS2 > Pool 2 (Server)
- Server to User: Pool 2 (Server) > VS2 > VS1 > User
Do I do SNAT Auto Map on both VS1 and VS2 or do I just do SNAT Auto Map on VS2 with Auto Last Hop enabled?
And on the question of persistence, if I intend to use source_addr persistence - I would definitely not be able to do a SNAT Auto Map on VS1, how do I then ensure that when the server responds, VS2 sends the traffic back to the user via VS1?