Both sites (www.site1.com & www.site2.com) are published to the world by the F5 and the SSL is being terminated by the F5 ( by the way, version 10.2.3 build 112.0 Final).
After I applied the given syntax to the VIP I still get content from site1 instead from site2.
* I do know that the condition line is working well ( if { [HTTP::uri] starts_with “/test” } ) because regular redirecting working well:
I have tried the syntax you suggested but I still get content from site1 (I’m checking this by browsing to https://www.site1.com/test/1.txt and this is how I know if i get content from site1 or site2)
In answer to your questions:
1. This is the only IRule applied on this VIP.
2. Site2 is another VIP which use other nodes than the nodes of Site1.
3. i didnt quite understand how to add the logging to the rule, if you can give them within an example syntax I could add them.
OK, that clears things up somewhat, thanks to Nitass too. Try this which will forward traffic to the site2 Virtual Server after the header replacement;
when HTTP_REQUEST {
if { (([string tolower [HTTP::uri]] starts_with "/test") && ([string tolower [HTTP::host]] equals "www.site1.com")) } {
log local0. "Matched host site1.com and uri /test"
HTTP::header replace Host "www.site2.com"
virtual 'site2-VS-name'
}
}
You’re welcome. You needed to specify the virtual as otherwise the traffic would be just be sent to the Pool Members in the default Pool configured for the original Virtual the iRule is applied to and these of course don’t host the site2 content; the Pool Members of the site2 VS do. Changing the header alone won’t get the traffic to the right place.
If you created a Pool with the site2 servers in it and then sent the traffic to it using the pool command rather than the virtual command that would work. Either way you would have to specifically route the traffic to the correct place unless site1’s Pool Members were also hosting site2.