For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Christian_12353's avatar
Christian_12353
Icon for Nimbostratus rankNimbostratus
May 21, 2014

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

  • Certainly. There are at least two ways:

    1. 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"
          }
      }
      
    2. 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.

  • 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"
        }
    }
    
  • 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"
        }
    }
    
  • Thanks. I should remove the pool correct on the HTTPS vip (website.com) once the irule is in place?

     

    Thanks.

     

    • nitass's avatar
      nitass
      Icon for Employee rankEmployee
      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.
  • 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

     

  • 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
    
    
  • 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.