Forum Discussion
help with url redirect
I had to create two separate VIPs due to SSL Certs. VIP1 work fine and redirect pool member as it should. VIP2 is using a different url, I need it to be redirected to a new url which is the VIP1 as long as the different ssl certs doen cause an error or rediect the the pool member with to correct url that the customer should see in the address bar.
I need customers coming in on VIP1 https://timesrv.bumpy.com/guest redirected to VIP2 https://ptotime.mycomp.com/quest via the virtual VIP or via pool member or preferably the pool....FYI its failing at the http_request section.
when CLIENT_ACCEPTED {
if { ( [expr [TCP::local_port] >= 5402] ) and ( [expr [TCP::local_port] <= 5405] ) } {
pool BumpyPool2
HTTP::disable
SSL::disable clientside
translate port disable
SSL::disable serverside
} elseif { [TCP::local_port] == 443 } {
return
} else {
reject
}
}
when HTTP_REQUEST {
switch [string tolower [HTTP::host]] {
timesrv.bumpy.com/guest { HTTP::redirect https://ptotime.mycomp.com/quest }
default { HTTP::respond 200 content "no such service" }
}
}
6 Replies
- AT_6064
Nimbostratus
.
- Arie
Altostratus
In your switch-statement you're checking for the host, but the first value ( timesrv.bumpy.com/guest ) includes a path.
If you're using dedicated VIPs for each host it suffices to check only against the path (HTTP::path). However, keep in mind that you may have to reckon with a trailing slash and default file names (e.g. index.html), which would probably also be valid ways to access the resource. - Gill_32697
Nimbostratus
i dont understand, so what should the irule look like? - Arie
Altostratus
switch [string tolower [HTTP::path]] {
/guest { HTTP::redirect https://ptotime.mycomp.com/quest }
default { HTTP::respond 200 content "no such service" }
}
Couple of things to keep in mind:
1) If you're using the same VIP for multiple domains you'll have to include a check for the right one(s).
2) The above won't catch requests to ptotime.mycomp.com/quest/ or ptotime.mycomp.com/quest/default.html (or whatever default page the app uses). However, both would be considered valid requests from the developer's perspective.
3) I'd consider using an HTTP Response Code other than 200 (OK), since "no such service" is not OK. - Gill_32697
Nimbostratus
Ok, got you, nice thats better. Ok great Thank you. - Arie
Altostratus
Glad it's working now!
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