Forum Discussion
iRule help - Redirect to different website when it matches with https
The MOST important consideration is in your 1 and 2 requirements. In order to "hide" the othersite URL from the user, you MUST proxy the traffic THROUGH the VIP. If you issue an HTTP::redirect, then sends a 302 type message back to the client with a Location header that causes the user to go directly to that URL (and away from your VIP). With that said, let's look at the rest of the requirements. First, for requirement 3, you need two VIPs: one HTTP and one HTTPS. The HTTP VIP simply uses the built-in _sys_https_redirect iRule and an HTTP profile. Nothing else is required. User traffic that hits this VIP will be automatically redirected to the HTTPS VIP with the same URI. For the HTTPS iRule:
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] contains "blog/" } {
pool othersite_pool
HTTP::header replace Host "www.othersite.com"
}
}
If some of the requests coming to the HTTPS VIP needs to go to othersite, then you'd just create a pool that points to that, make sure the F5 can route to that site, add a SNAT profile to the VIP and the above iRule. Client requests will be forwarded (through the proxy) to the other site with a replaced Host header.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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