Forum Discussion
Hi!
I think I understood your request.
The reason why the location in the client browser changes is that you keep adding a HTTP::redirect to the iRules. An HTTP redirect would send a response to the client asking it to get the content from another domain/uri, and as you said, this is not what you want.
If you are using the same pool for lion and bearcub I assume that you're using host headers to separate requests to the two different sites and thus you need to replace the host if you want the request to end up at another site than the original request:
Let's look at the rule again and I'll explain each step with comments:
The rule will be executed whenever there is an HTTP request
when HTTP_REQUEST {
Saving the host header and the URI to variables
set host [string tolower [HTTP::host]]
set uri [string tolower [HTTP::uri]]
Comparing the host header and the URI to know when to rewrite the host header
In this case it would only trigger if the client uses lion.dev.leo.world.com
and the uri starts with /lookout.
That would include uris like /lookout, /lookout/index.aspx, /lookout/style.css etc.
if { $host equals "lion.dev.leo.world.com" and $uri starts_with "/lookout" } {
Replaces the host header in the packet with bearcub.dev.leo.world.com
By replacing the host header with bearcub.dev.leo.world.com the request would
be sent to the bearcub site
HTTP::header replace Host "bearcub.dev.leo.world.com"
Logging any requests matching the conditions above
log local0. "Sending to the bearcub pool because of host: $host and uri: $uri"
}
}
This would mean that the load balancer would replace the host header for all requests destined for lion.dev.leo.world.com with an uri that starts with /lookout. It would do this before sending the request on to the server.
Note that if /lookout includes any other objects that does not reside under /lookout (ie "/styles/style.css") they would not go to bearcubs, but to lions.
/Patrik