Forum Discussion

whootang's avatar
whootang
Icon for Nimbostratus rankNimbostratus
Oct 07, 2017

iRule to host multiple site redirects on one VIP

Hi Guys

 

I am trying to search/figure out is it possible to have one VIP (1 IP address) to host multiple domain redirects.

 

for example i want to redirect,

 

sitea.com to google.com siteb.com to msn.com sitec.com to yahoo.com

 

As i have about 30 sites i want to redirect but IPs in this space are very limited due to various reasons.

 

Can this be done? or is there another why i can do this.

 

thanks foe your time

 

2 Replies

  • Of course you can do it with BigIP.

     

    I'm not sure if you want to forward (like a reverse proxy) or to redirect (301 / 302 responses)

     

    you can do it with irules or Local traffic policies. The easiest solution is local traffic policy (only 302 redirect are available in policies, 301 is available in irules only).

     

    It's a ordered rule base policy with conditions and actions

     

  • Hi Guy,

    If you want only to HTTP redirect, create a Virtual server, define all DNS records of your sites as this virtual server IP, after that create a data group like the following and add the following iRule to your VS.
    urllist data group
    "sitea.com" := "google.com",
    "siteb.com" := "msn.com",
    "sitec.com" := "yahoo.com",
    
    when HTTP_REQUEST {
    if {[set redir_url [class match -value -- [string tolower [HTTP::host][HTTP::uri]] equals urllist]] ne "" }{
    HTTP::redirect $redir_url
    }
    }