Forum Discussion

Bob_May_78337's avatar
Bob_May_78337
Icon for Nimbostratus rankNimbostratus
Feb 12, 2014

Host_Header IRule for F5 LTM

I am trying to create an IRule to read an incoming host_header and based on the host_header, forward this request to another VirtualServer. I have seen examples to forward to server pools, but not to a different virtual server vip. Any help will be appreciated!!

 

7 Replies

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    Are you looking for an HTTP redirect or masking it (i.e. connect to another destination without changing the URL)?

     

  • Say I have the below vip setup in the LTM: VS: 10.186.41.15 for host www.test.com and is the only vip accessible to the user population. I then create another LTM VS vip: 10.186.41.16 for www.dummy.com, which is "not" accessible to the user population.

     

    I setup my dns to have both websites, "www.test.com & www.dummy.com" to point to 10.186.41.15 for resolution.

     

    I want to create an IRule and assign it to the vip 10.186.41.15, that says any incoming request which has "www.dummy.com" in the host_header, forward this request to the vip 10.186.41.16.

     

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    The best way to accomplish what you're looking for is to point both DNS-records to the same VIP, create separate pools for each of the domains, and use an iRule to select the pool based on the host.

     

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    Theoretically it's possible, but it would be a poor approach. The proper way is to use pools.

     

  • It's totally possible.

    when HTTP_REQUEST {
        if { [string tolower [HTTP::host]] equals "www.dummy.com" } {
            virtual dummy_vs
        }
    }
    

    where "dummy_vs" might be the name of the dummy virtual server. Best part, because you're using the virtual command, the dummy VIP's destination address doesn't have to be routable.