Forum Discussion
VIP redirect to another VIP
Hello,
I was wondering if there was a way to redirect to another VIP..
so if traffic comes in to one VIP.. an irule or something would send it to another VIP on the same LTM.
Thanks
Any help would be great.
Thank you
9 Replies
- Kevin_Stewart
Employee
Certainly. There are at least two ways:
-
Explicit HTTP redirect - this is where you issue an explicit 302 redirect to send the client browser somewhere else. It can be done with an iRule, an HTTP class (11.3 and below), or a policy (11.4 and above). It's actually a pretty common use case to redirect from an HTTP VIP to an HTTPS VIP. So common in fact that there's a built-in iRule for it. It might look something like this:
when HTTP_REQUEST { if { ...some condition... } { HTTP::redirect "https://somewhere.else.com" } }You can also use the HTTP::respond command for a bit more flexibility.
when HTTP_REQUEST { if { ...some condition... } { HTTP::respond 301 Location "https://somewhere.else.com" } } -
VIP targeting - this is where you basically put one VIP in front of another one. The external VIP would have your publicly-accessible destination IP and port, and would forward the traffic to the internal, potentially non-routable VIP via an iRule and the virtual command. Here's an example:
when HTTP_REQUEST { if { ...some condition... } { virtual internal-vs } }where "internal-vs" is the name of the internal VIP.
-
- Kevin_Stewart
Employee
so if I have a website like www.website.com and want to redirect to www.newsite.com.. would it look like the below?
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "www.website.com" } { HTTP::redirect "http://www.newsite.com" } } - Kevin_Stewart
Employee
As long as you're offloading the SSL on the HTTPS VIP, the iRule should work the same for both.
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "website.com" } { HTTP::redirect "https://NEWwebsite.com" } } - Christian_12353
Nimbostratus
Thanks. I should remove the pool correct on the HTTPS vip (website.com) once the irule is in place?
Thanks.
- nitass
Employee
i guess newwebsite.com is on different virtual server, isn't it? if yes, yes you can remove the pool unless you have another traffic to this https (website.com) virtual server which domain is not website.com.
- Christian_12353
Nimbostratus
yeah.. so basically we have..
a VIP website.com this VIP has a http://website.com with a redirect to https://website.com
we want both of those to redirect to another VIP https://NEWwebsite.com
I tried the above irule on http://website.com and https://website.com but it didnt seem like it worked..am I missing something?
Please advise..
Thanks for your help
- nitass
Employee
I tried the above irule on http://website.com and https://website.com but it didnt seem like it worked..am I missing something?
doesn't the irule Kevin suggested work?
config root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar ltm virtual bar { destination 172.28.24.10:80 ip-protocol tcp mask 255.255.255.255 profiles { http { } tcp { } } rules { qux } source 0.0.0.0/0 vs-index 35 } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux ltm rule qux { when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "website.com" } { HTTP::redirect "https://NEWwebsite.com" } } } test [root@ve11a:Active:In Sync] config curl -I http://172.28.24.10 -H "Host: website.com" HTTP/1.0 302 Found Location: https://NEWwebsite.com Server: BigIP Connection: Keep-Alive Content-Length: 0 - Christian_12353
Nimbostratus
Ok.. So the irule should work. so it must be something I am doing wrong. Let me try again.
If I still cant get it.. I might call and see if I can do a webex with support.
Thanks.
- nitass
Employee
you may try http analyzer tool, such as httpfox, to see if it is helpful.
HttpFox
https://addons.mozilla.org/en-US/firefox/addon/httpfox/
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